Centos7下安装部署MXNET
Centos下安装MXNET,参考官方文档http://mxnet.io/get_started/setup.html#prerequisites,
一、安装python的mxnet步骤如下:
#!/usr/bin/env bash ###################################################################### # This script installs MXNet for Python along with all required dependencies on a Fedora Machine. # Tested on Fedora 21.0 + distro. ###################################################################### set -e MXNET_HOME="$HOME/mxnet/" echo "MXNet root folder: $MXNET_HOME" echo "Installing basic development tools, atlas, opencv, pip, graphviz ..." sudo yum update sudo yum groupinstall -y "Development Tools" "Development Libraries" sudo yum install -y atlas atlas-devel opencv opencv-devel graphviz graphviz-devel echo "Building MXNet core. This can take few minutes..." cd "$MXNET_HOME" make -j$(nproc) echo "Installing Numpy..." sudo yum install numpy echo "Installing Python setuptools..." sudo yum install -y python-setuptools python-pip echo "Adding MXNet path to your ~/.bashrc file" echo "export PYTHONPATH=$MXNET_HOME/python:$PYTHONPATH" >> ~/.bashrc source ~/.bashrc echo "Install Graphviz for plotting MXNet network graph..." sudo pip install graphviz echo "Installing Jupyter notebook..." sudo pip install jupyter echo "Done! MXNet for Python installation is complete. Go ahead and explore MXNet with Python :-)"
测试下是否安装成功:
>>> import mxnet as mx >>>
ok,成功!
1 error解决:
1.1 安装opencv需要注意的地方:
1)、如果停在了下载ippicv的地方,可以自行下载ippicv_linux_20151201.tgz(链接:http://www.linuxfromscratch.org/blfs/view/7.9/general/opencv.html),
然后将刚才下载的ippicv文件直接拷贝进入opencv源码的下面这个目录:3rdparty/ippicv/downloads/linux-808b791a6eac9ed78d32a7666804320e
2)、错误:/usr/bin/ld: /usr/local/include/../lib/libswscale.a(swscale.o): relocation R_X86_64_PC32 against symbol `ff_M24A' can not be used when making a shared object; recompile with -fPIC
需要使用PIC选项重新编译ffmpeg: CFLAGS="-O3 -fPIC" ./configure --enable-nonfree --enable-pic --enable-shared
若ffmpeg正常安装后执行ffmpeg时出现如下错误:ffmpeg: error while loading shared libraries: libavdevice.so.57: cannot open shared object file: No such file or directory
则 vim /etc/ld.so.conf 加入:/usr/local/lib 执行 ldconfig
如果上面的方法都失败,那么需要如下处理:将FFmpeg静态库更改为使用动态:
sed -i -e 's/libavformat\.a/libavformat.so/g' \ -e 's/libavutil\.a/libavutil.so/g' \ -e 's/libswscale\.a/libswscale.so/g' \ -e 's/libavresample\.a/libavresample.so/g' \ -e 's/libavcodec\.a/libavcodec.so/g' \ cmake/OpenCVFindLibsVideo.cmake
然后:
cmake -D BUILD_opencv_gpu=OFF -D WITH_EIGEN=ON -D WITH_TBB=ON -D WITH_CUDA=OFF -D WITH_TIFF=OFF -DWITH_IPP=OFF -D WITH_1394=OFF -D CMAKE_BUILD_TYPE=RELEASE -DWITH_FFMPEG=ON -DWITH_GSTREAMER=OFF -D CMAKE_INSTALL_PREFIX=/usr/local
.. sudo make PREFIX=/usr/local install
1.2 安装nnvm错误解决
1)如果出现这个错误:/usr/bin/ld: cannot find -lcblas
cd /usr/lib64
ln -s libcblas.so.3 libcblas.so
二、安装R包mxnet
#!/usr/bin/env bash ###################################################################### # This script installs MXNet for R along with all required dependencies on a Ubuntu Machine. # We recommend to install Microsoft RServer together with Intel MKL library for optimal performance # More information can be found here: # https://blogs.technet.microsoft.com/machinelearning/2016/09/15/building-deep-neural-networks-in-the-cloud-with-azure-gpu-vms-mxnet-and-microsoft-r-server/ # Tested on Ubuntu 14.04+ distro. ###################################################################### set -e MXNET_HOME="$HOME/mxnet/" echo "MXNet root folder: $MXNET_HOME" echo "Building MXNet core. This can take few minutes..." cd "$MXNET_HOME" make -j$(nproc) echo "Installing R dependencies. This can take few minutes..." # make sure we have essential tools installed is_rscript_installed=$(which Rscript | wc -l) if [ "$is_rscript_installed" = "0" ]; then read -p "Seems like Rscript is not installed. Install Rscript? [Y/n]" if [ x"$REPLY" = x"" -o x"$REPLY" = x"y" -o x"$REPLY" = x"Y" ]; then sudo apt-get install -y r-base-core fi fi # libcurl4-openssl-dev and libssl-dev are needed for devtools. sudo apt-get -y install libcurl4-openssl-dev libssl-dev # Needed for R XML sudo apt-get install libxml2-dev sudo Rscript -e "install.packages('devtools', repo = 'https://cran.rstudio.com')" cd R-package sudo Rscript -e "library(devtools); library(methods); options(repos=c(CRAN='https://cran.rstudio.com')); install_deps(dependencies = TRUE)" cd .. echo "Compiling R package. This can take few minutes..." sudo make rpkg echo "Installing R package..." sudo R CMD INSTALL mxnet_current_r.tar.gz echo "Done! MXNet for R installation is complete. Go ahead and explore MXNet with R :-)"
测试下是否安装成功:
> library(mxnet) Init Rcpp> > > a <- mx.nd.ones(c(2,3)) > a [,1] [,2] [,3] [1,] 1 1 1 [2,] 1 1 1
ok!