CXXNET是深度学习的高效库,在安装好了caffe之后再安装CXXNET的话,非常简单,因为它们的依赖库差不多。
本文主要就是介绍在安装了caffe之后再安装CXXNET的步骤。如果还没有安装caffe,可以参考这里。
安装平台:ubuntu14.04 LTS 64位。
1、CXXNET 下载。
2、解压文件,然后把 make/config.mk复制到 cxxnet-master文件夹下面
3、编辑复制后的 config.mk .
#-----------------------------------------------------
# cxxnet: the configuration compile script
#
# This is the default configuration setup for cxxnet
# If you want to change configuration, do the following steps:
#
# - copy this file to the root folder
# - modify the configuration you want
# - type make or make -j n for parallel build
#----------------------------------------------------
# choice of compiler
export CC = gcc
export CXX = g++
export NVCC = nvcc
# whether use CUDA during compile
USE_CUDA = 1
# add the path to CUDA libary to link and compile flag
# if you have already add them to enviroment variable, leave it as NONE
USE_CUDA_PATH =/usr/local/cuda-6.5
CUDA_DIR := /usr/local/cuda
# whether use opencv during compilation
# you can disable it, however, you will not able to use
# imbin iterator
USE_OPENCV = 1
USE_OPENCV_DECODER = 1
# whether use CUDNN R3 library
USE_CUDNN = 0
# add the path to CUDNN libary to link and compile flag
# if you do not need that, or do not have that, leave it as NONE
USE_CUDNN_PATH = NONE
#
# choose the version of blas you want to use
# can be: mkl, blas, atlas, openblas
USE_STATIC_MKL = /opt/intel/composer_xe_2015.1.133
USE_BLAS = mkl
#
# add path to intel libary, you may need it
# for MKL, if you did not add the path to enviroment variable
#
USE_INTEL_PATH = NONE
# whether compile with parameter server
USE_DIST_PS = 0
PS_PATH = NONE
PS_THIRD_PATH = NONE
# the additional link flags you want to add
ADD_LDFLAGS = -ljpeg
# the additional compile flags you want to add
ADD_CFLAGS =
#
# If use MKL, choose static link automaticly to fix python wrapper
#
ifeq ($(USE_BLAS), mkl)
USE_STATIC_MKL = 1
endif
这里的mkl和cuda都是采用默认路径安装。
4、sudo sh ./build.sh 就开始build了。这里可能会出现一些问题,比如我的是找不到liomp5这个库,其实它是存在的。所以我就建立了一个软连接 sudo ln -s /opt/intel/composer_xe_2015.1.133/compiler/lib/intel64/libiomp5.so /usr/lib/libiomp5.so 如果遇到类似的问题,只要建立链接即可。
5、cd tools
6、sudo make
大功告成了!可以去example下面跑两个试试,我跑了下 sudo sh run.sh ./MNIST_CONV.conf, 结果如下:
Use CUDA Device 0: GeForce GTX 680
finish initialization with 1 devices
Initializing layer: cv1
Initializing layer: 1
Initializing layer: 2
Initializing layer: 3
Initializing layer: fc1
Initializing layer: se1
Initializing layer: fc2
Initializing layer: 7
SGDUpdater: eta=0.100000, mom=0.900000
SGDUpdater: eta=0.100000, mom=0.900000
SGDUpdater: eta=0.100000, mom=0.900000
SGDUpdater: eta=0.100000, mom=0.900000
SGDUpdater: eta=0.100000, mom=0.900000
SGDUpdater: eta=0.100000, mom=0.900000
node[in].shape: 100,1,28,28
node[1].shape: 100,32,14,14
node[2].shape: 100,32,7,7
node[3].shape: 100,1,1,1568
node[4].shape: 100,1,1,100
node[5].shape: 100,1,1,100
node[6].shape: 100,1,1,10
MNISTIterator: load 60000 images, shuffle=1, shape=100,1,28,28
MNISTIterator: load 10000 images, shuffle=0, shape=100,1,28,28
initializing end, start working
round 0:[ 600] 2 sec elapsed[1] train-error:0.211783 test-error:0.0435
round 1:[ 600] 4 sec elapsed[2] train-error:0.0522667 test-error:0.0263
round 2:[ 600] 5 sec elapsed[3] train-error:0.0370833 test-error:0.0214
round 3:[ 600] 7 sec elapsed[4] train-error:0.0316167 test-error:0.023
round 4:[ 600] 8 sec elapsed[5] train-error:0.02905 test-error:0.0152
round 5:[ 600] 10 sec elapsed[6] train-error:0.0265167 test-error:0.0166
round 6:[ 600] 12 sec elapsed[7] train-error:0.0248333 test-error:0.0164
round 7:[ 600] 13 sec elapsed[8] train-error:0.0226667 test-error:0.0144
round 8:[ 600] 15 sec elapsed[9] train-error:0.0234167 test-error:0.0139
round 9:[ 600] 17 sec elapsed[10] train-error:0.0221 test-error:0.0152
round 10:[ 600] 18 sec elapsed[11] train-error:0.0218667 test-error:0.0121
round 11:[ 600] 20 sec elapsed[12] train-error:0.02025 test-error:0.0128
round 12:[ 600] 22 sec elapsed[13] train-error:0.01925 test-error:0.0142
round 13:[ 600] 23 sec elapsed[14] train-error:0.0194333 test-error:0.0129
round 14:[ 600] 25 sec elapsed[15] train-error:0.0190167 test-error:0.0114
updating end, 25 sec in all
速度极快!呵呵。
朋友你如果对深度学习感兴趣,我很希望能和你相互学习交流。