Install MXNet on CentOS

原文鏈接:

http://mxnet.io/get_started/centos_setup.html

mxnet

MXNet currently supports Python, R, Julia, and Scala. For users on CentOS with Docker environment, MXNet providesDocker installation guide. If you do not have a Docker environment set up, follow below-provided step by step instructions.

Minimum Requirements

Make sure you have the root permission, andyumis properly installed. Check it using the following command:

sudo yum check-update

If you don’t get an error message, thenyumis installed.

To install MXNet on CentOS, you must have the following:

gcc, g++ (4.8 or later)

python2, python-numpy, python-pip, clang

graphviz, jupyter (pip or yum install)

OpenBLAS

CUDA for GPU

cmake and opencv (do not use yum to install opencv, some shared libs may not be installed)

Install Dependencies

Make sure your machine is connected to Internet. A few installations need to download (gitcloneorwget) some packages from Internet.

Install Basic Environment

# Install gcc-4.8/make and other development toolssudo yum install -y gcc? ? sudo yum install -y gcc-c++? ? sudo yum install -y clang# Install Python, Numpy, pip and set up tools.sudo yum groupinstall -y"Development Tools"sudo yum install -y python27 python27-setuptools python27-tools python-pip? ? sudo yum install -y python27-numpy# install graphviz, jupytersudo pip install graphviz? ? sudo pip install jupyter

Install OpenBLAS

Note that OpenBLAS can be replaced by other BLAS libs, e.g, Intel MKL.

# Install OpenBLAS at /usr/local/openblasgit clone https://github.com/xianyi/OpenBLAScdOpenBLAS? ? make -j$(($(nproc)+1))sudo makePREFIX=/usr/local installcd..

Install CUDA for GPU

Note: Setting up CUDA is optional for MXNet. If you do not have a GPU machine (or if you want to train with CPU), you can skip this section and proceed with installation of OpenCV.

If you plan to build with GPU, you need to set up the environment for CUDA and CUDNN.

First, download and installCUDA 8 toolkit.

Then downloadcudnn 5.

Unzip the file and change to the cudnn root directory. Move the header and libraries to your local CUDA Toolkit folder:

tar xvzf cudnn-8.0-linux-x64-v5.1-ga.tgz? ? sudo cp -P cuda/include/cudnn.h /usr/local/cuda/include? ? sudo cp -P cuda/lib64/libcudnn* /usr/local/cuda/lib64? ? sudo chmod a+r /usr/local/cuda/include/cudnn.h /usr/local/cuda/lib64/libcudnn*? ? sudo ldconfig

Install opencv

Note: Setting up opencv is optional but strongly recommended for MXNet, unless you do not want to work on Computer Vision and Image Augmentation. If you are quite sure about that, skip this section and setUSE_OPENCV=0inconfig.mk.

The Open Source Computer Vision (OpenCV) library contains programming functions for computer vision and image augmentation. For more information, seeOpenCV.

# Install cmake for building opencvsudo yum install -y cmake# Install OpenCV at /usr/local/opencvgit clone https://github.com/opencv/opencvcdopencv? ? mkdir -p buildcdbuild? ? cmake -DBUILD_opencv_gpu=OFF -DWITH_EIGEN=ON -DWITH_TBB=ON -DWITH_CUDA=OFF -DWITH_1394=OFF -DCMAKE_BUILD_TYPE=RELEASE -DCMAKE_INSTALL_PREFIX=/usr/local ..? ? sudo makePREFIX=/usr/local install

Install MXNet

Build MXNet shared library

After installing the dependencies, use the following command to pull the MXNet source code from GitHub.

# Download MXNet source code to ~/mxnet directorygit clone https://github.com/dmlc/mxnet.git ~/mxnet --recursive# Move to source code parent directorycd~/mxnet? ? cp make/config.mk .# Replace this line if you use other BLAS libsecho"USE_BLAS=openblas">>config.mkecho"ADD_CFLAGS += -I/usr/include/openblas">>config.mkecho"ADD_LDFLAGS += -lopencv_core -lopencv_imgproc -lopencv_imgcodecs">>config.mk

If building withGPUsupport, run below commands to add GPU dependency configurations toconfig.mkfile:

echo"USE_CUDA=1">>config.mkecho"USE_CUDA_PATH=/usr/local/cuda">>config.mkecho"USE_CUDNN=1">>config.mk

Then build mxnet:

make -j$(nproc)

Executing these commands creates a library calledlibmxnet.soin~/mxnet/lib/.

Install MXNet for Python

Next, we install Python interface for MXNet. Assuming you are in~/mxnetdirectory, run below commands.

# Install MXNet Python packagecdpython? ? sudo python setup.py install

Check if MXNet is properly installed.

# You can change mx.cpu to mx.gpupython? ? >>> import mxnet as mx? ? >>>a=mx.nd.ones((2, 3), mx.cpu())>>> print((a * 2).asnumpy())[[2.? 2.? 2.][2.? 2.? 2.]]

If you don’t get an import error, then MXNet is ready for python.

Note: You can update mxnet for python by repeating this step after re-buildinglibmxnet.so.

Install MXNet for R, Julia and Scala

R

Julia

Scala

Troubleshooting

Here is some information to help you troubleshoot, in case you encounter error messages:

1. Cannot build opencv from source code

This may be caused by download failure during building, e.g.,ippicv.

Prepare some large packages by yourself, then copy them to the right place, e.g,opencv/3rdparty/ippicv/downloads/linux-808XXXXXXXXX/.

2. Link errors when building MXNet

/usr/bin/ld: /tmp/ccQ9qruP.o: undefined reference to symbol'_ZN2cv6String10deallocateEv'/usr/local/lib/libopencv_core.so.3.2: error adding symbols: DSO missing fromcommandline

This error occurs when you already have old opencv (e.g, 2.4) installed usingyum(in/usr/lib64). When g++ tries to link opencv libs, it will first find and link old opencv libs in/usr/lib64.

Please modifyconfig.mkinmxnetdirectory, and add-L/usr/local/libtoADD_CFLAGS.

ADD_CFLAGS +=-I/usr/include/openblas -L/usr/local/lib

This solution solves this link error, but there are still lots of warnings.

Next Steps

Tutorials

How To

Architecture

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
  • 序言:七十年代末,一起剝皮案震驚了整個(gè)濱河市士飒,隨后出現(xiàn)的幾起案子,更是在濱河造成了極大的恐慌,老刑警劉巖坝辫,帶你破解...
    沈念sama閱讀 212,718評(píng)論 6 492
  • 序言:濱河連續(xù)發(fā)生了三起死亡事件,死亡現(xiàn)場(chǎng)離奇詭異劣像,居然都是意外死亡粘衬,警方通過(guò)查閱死者的電腦和手機(jī),發(fā)現(xiàn)死者居然都...
    沈念sama閱讀 90,683評(píng)論 3 385
  • 文/潘曉璐 我一進(jìn)店門(mén)貌笨,熙熙樓的掌柜王于貴愁眉苦臉地迎上來(lái)弱判,“玉大人,你說(shuō)我怎么就攤上這事锥惋〔” “怎么了?”我有些...
    開(kāi)封第一講書(shū)人閱讀 158,207評(píng)論 0 348
  • 文/不壞的土叔 我叫張陵膀跌,是天一觀(guān)的道長(zhǎng)。 經(jīng)常有香客問(wèn)我,道長(zhǎng)磷杏,這世上最難降的妖魔是什么难衰? 我笑而不...
    開(kāi)封第一講書(shū)人閱讀 56,755評(píng)論 1 284
  • 正文 為了忘掉前任,我火速辦了婚禮,結(jié)果婚禮上祠汇,老公的妹妹穿的比我還像新娘仍秤。我一直安慰自己,他們只是感情好可很,可當(dāng)我...
    茶點(diǎn)故事閱讀 65,862評(píng)論 6 386
  • 文/花漫 我一把揭開(kāi)白布诗力。 她就那樣靜靜地躺著,像睡著了一般我抠。 火紅的嫁衣襯著肌膚如雪苇本。 梳的紋絲不亂的頭發(fā)上,一...
    開(kāi)封第一講書(shū)人閱讀 50,050評(píng)論 1 291
  • 那天屿良,我揣著相機(jī)與錄音圈澈,去河邊找鬼。 笑死尘惧,一個(gè)胖子當(dāng)著我的面吹牛康栈,可吹牛的內(nèi)容都是我干的。 我是一名探鬼主播喷橙,決...
    沈念sama閱讀 39,136評(píng)論 3 410
  • 文/蒼蘭香墨 我猛地睜開(kāi)眼啥么,長(zhǎng)吁一口氣:“原來(lái)是場(chǎng)噩夢(mèng)啊……” “哼!你這毒婦竟也來(lái)了贰逾?” 一聲冷哼從身側(cè)響起悬荣,我...
    開(kāi)封第一講書(shū)人閱讀 37,882評(píng)論 0 268
  • 序言:老撾萬(wàn)榮一對(duì)情侶失蹤,失蹤者是張志新(化名)和其女友劉穎疙剑,沒(méi)想到半個(gè)月后氯迂,有當(dāng)?shù)厝嗽跇?shù)林里發(fā)現(xiàn)了一具尸體,經(jīng)...
    沈念sama閱讀 44,330評(píng)論 1 303
  • 正文 獨(dú)居荒郊野嶺守林人離奇死亡言缤,尸身上長(zhǎng)有42處帶血的膿包…… 初始之章·張勛 以下內(nèi)容為張勛視角 年9月15日...
    茶點(diǎn)故事閱讀 36,651評(píng)論 2 327
  • 正文 我和宋清朗相戀三年嚼蚀,在試婚紗的時(shí)候發(fā)現(xiàn)自己被綠了。 大學(xué)時(shí)的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片管挟。...
    茶點(diǎn)故事閱讀 38,789評(píng)論 1 341
  • 序言:一個(gè)原本活蹦亂跳的男人離奇死亡轿曙,死狀恐怖,靈堂內(nèi)的尸體忽然破棺而出僻孝,到底是詐尸還是另有隱情导帝,我是刑警寧澤,帶...
    沈念sama閱讀 34,477評(píng)論 4 333
  • 正文 年R本政府宣布穿铆,位于F島的核電站您单,受9級(jí)特大地震影響,放射性物質(zhì)發(fā)生泄漏悴务。R本人自食惡果不足惜睹限,卻給世界環(huán)境...
    茶點(diǎn)故事閱讀 40,135評(píng)論 3 317
  • 文/蒙蒙 一譬猫、第九天 我趴在偏房一處隱蔽的房頂上張望。 院中可真熱鬧羡疗,春花似錦染服、人聲如沸。這莊子的主人今日做“春日...
    開(kāi)封第一講書(shū)人閱讀 30,864評(píng)論 0 21
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽(yáng)。三九已至痒钝,卻和暖如春秉颗,著一層夾襖步出監(jiān)牢的瞬間,已是汗流浹背送矩。 一陣腳步聲響...
    開(kāi)封第一講書(shū)人閱讀 32,099評(píng)論 1 267
  • 我被黑心中介騙來(lái)泰國(guó)打工蚕甥, 沒(méi)想到剛下飛機(jī)就差點(diǎn)兒被人妖公主榨干…… 1. 我叫王不留,地道東北人栋荸。 一個(gè)月前我還...
    沈念sama閱讀 46,598評(píng)論 2 362
  • 正文 我出身青樓菇怀,卻偏偏與公主長(zhǎng)得像,于是被迫代替她去往敵國(guó)和親晌块。 傳聞我的和親對(duì)象是個(gè)殘疾皇子爱沟,可洞房花燭夜當(dāng)晚...
    茶點(diǎn)故事閱讀 43,697評(píng)論 2 351

推薦閱讀更多精彩內(nèi)容