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 thewebsite of opencv, follow theinstallation 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, 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

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值