Deep Learning Framework CXXNET Compilation
CXXNET is a fast, concise, distributed deep learning framework based on MShadow.It is a lightweight and easy extensible C++/CUDA neural network toolkit with friendly Python/Matlab interface for training and prediction. It is very helpful to construct a deep neural network. Recently, I compiled this framework on the server of my laboratory, during the compilation, I met some difficulties, also made some mistake. So I write these difficulties and mistake down, in case I will compile it again in the future, also hope it will be helpful to those who want to use cxxnet.
Because I don't have root privilege of the server, so maybe some of my actions don't fit you if you have the root privilege, I will explain these actions as clear as possible.
Download source code
You can download the source code from the Github :[CXXNET][], either download the zip package or use git clone in command line is ok.
Configure dependencies
CXXNET is depend on opencv and MShadow, if you want to use GPU to accelerate your learning process, you also need to install cuda. Unfortunately, there is no Nvidia graphic card on my server, so I didn't install cuda.
Again, because I don't have root privilege, so I install all software in MY\_HOME/software, MY\_HOME is the home directory of my account, you should replace it with your home directory.
If you have already installed any of the dependencies below, just skip the corresponding step.
#
Opencv
Download the appropriate version of source code from the[website of opencv][], follow the[installation documentation][], after installation, you need to add the OPENCV\_INSTALL\_PATH/bin to you environment variable PATH, OPENCV\_INSTALL\_PATH is the path you install opencv, for me, it is MY\_HOME/software/opencv. Also, you need to add OPENCV\_INSTALL\_PATH/lib to environment variable LD\_LIBRARY\_PATH, which make it possible to link the library of opencv while compiling cxxnet. You need to export these two environment variables in ~/.bashrc, or /etc/profile if you have root privilege.(e.g. export PATH=OPENCV\_INSTALL\_PATH/bin:$PATH).
MKL
After installing opencv, you can try building cxxnet, if there is error saying"mkl.h not found", you should read this part. MKL is the abbreviate of Math Kernel Library, developed by intel. There is noncommercial version for students and researchers on [https://software.intel.com/zh-cn/qualify-for-free-software][https_software.intel.com_zh-cn_qualify-for-free-software], following the instructions, you can get a free parallel studio. Run install.sh, and follow the instruction, you will install mkl on your machine, remember you got a serial number when you provide your email address. After installation, you should add bin and lib to PATH andLD\_LIBRARY\_PATH,
export PATH=”:INTEL_INSTALL_PATH/bin:$PATH”
export LD_LIBRARY_PATH=$LD_LIBRARY_LIB:INTEL_INSTALL_PATH/lib/intel64:INTEL_INSTALL_PATH/mkl/lib/intel64
INTEL_INSTALL_PATH is the path the software installed.
Compilation of CXXNET
After dealing with the dependencies, it should be quite easy to compile cxxnet according to the README.md in the source code directory. However, when I tried to compile, there was still some errors include header files of opencv, I am nor sure if I made mistakes in installation, or if it is because I install opencv and MKL in MY_HOME/software, rather than /opt. I read the Makefile, and found that the header file directory is not included in Makefile. Concretely, line 25 in Makefile add the path of opencv library to LDFLAGS, but didn’t add the header filie directory to CFLAGS, so I add the code below after the line 25.
CFLAGS+= `pkg-config --cflags opencv`
It is not done yet, because opencv is install in MY\_HOME/software, rather than /opt, so pkg-config cannot find opencv.pc, so we must tell pkg-config where the opencv.pc is, in the OPENCV\_INSTALL\_PATH/lib/pkgconfig, you will find it. So the last step is to add OPENCV\_INSTALL\_PATH/lib/pkgconfig to environment variable PKG\_CONFIG\_PATH.
After all these steps, you can build the cxxnet successfully, remember to replace 'dev=gpu' with 'dev=cpu' in config.mk if you don't have nvidia display card.
I hope this blog with be helpful to you .
PS: This is my first English blog(acctually I didn't write many Chinese blogs neither), because my English is poor, so I want to improve English by writing something. There must be many grammer mistake in this blog. I will be very grateful if you can tell me where the mistake is.
Reference
http://blog.csdn.net/ray_up/article/details/38683383
还没有评论,来说两句吧...