Installing MXNet on CentOS¶
NOTE: For MXNet with Python installation, please refer to the new install guide.
MXNet currently supports Python, R, Julia, Scala, and Perl. For users on CentOS with Docker environment, MXNet provides Docker installation guide. If you do not have a Docker environment set up, follow below-provided step by step instructions.
Make sure you have the root permission, and
yum is properly installed. Check it using the following command:
sudo yum check-update
If you don’t get an error message, then
yum is 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)
- CUDA for GPU
- cmake and opencv (do not use yum to install opencv, some shared libs may not be installed)
Make sure your machine is connected to Internet. A few installations need to download (
git clone or
wget) some packages from Internet.
Install Basic Environment¶
# Install gcc-4.8/make and other development tools sudo 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, jupyter sudo pip install graphviz sudo pip install jupyter
Note that OpenBLAS can be replaced by other BLAS libs, e.g, Intel MKL.
# Install OpenBLAS at /usr/local/openblas git clone https://github.com/xianyi/OpenBLAS cd OpenBLAS make -j $(($(nproc) + 1)) sudo make PREFIX=/usr/local install cd ..
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 install CUDA 8 toolkit.
Then download cudnn 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
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 set
USE_OPENCV = 0 in
The Open Source Computer Vision (OpenCV) library contains programming functions for computer vision and image augmentation. For more information, see OpenCV.
# Install cmake for building opencv sudo yum install -y cmake # Install OpenCV at /usr/local/opencv git clone https://github.com/opencv/opencv cd opencv mkdir -p build cd build cmake -D BUILD_opencv_gpu=OFF -D WITH_EIGEN=ON -D WITH_TBB=ON -D WITH_CUDA=OFF -D WITH_1394=OFF -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local .. sudo make PREFIX=/usr/local install
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.,
Prepare some large packages by yourself, then copy them to the right place, e.g,
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 from command line
This error occurs when you already have old opencv (e.g, 2.4) installed using
/usr/lib64). When g++ tries to link opencv libs, it will first find and link old opencv libs in
mxnet directory, and add
ADD_CFLAGS += -I/usr/include/openblas -L/usr/local/lib
This solution solves this link error, but there are still lots of warnings.