redhat配置caffe多核训练
参考网站:
http://blog.csdn.net/10km/article/details/52723306
http://stackoverflow.com/questions/31395729/how-to-enable-multithreading-with-caffe
redhat配置caffe多核训练
一、安装openblas
要利用openblas进行加速
安装
-
sudo yum install openblas-devel
查看安装的路径
-
rpm -ql openblas-devel
1 /usr/include/openblas 2 /usr/include/openblas/cblas.h 3 /usr/include/openblas/f77blas.h 4 /usr/include/openblas/lapacke.h 5 /usr/include/openblas/lapacke_config.h 6 /usr/include/openblas/lapacke_mangling.h 7 /usr/include/openblas/lapacke_utils.h 8 /usr/include/openblas/openblas_config.h 9 /usr/lib64/libopenblas.so 10 /usr/lib64/libopenblaso.so 11 /usr/lib64/libopenblasp.so
/usr/include/openblas
/usr/include/openblas/cblas.h
/usr/include/openblas/f77blas.h
/usr/include/openblas/lapacke.h
/usr/include/openblas/lapacke_config.h
/usr/include/openblas/lapacke_mangling.h
/usr/include/openblas/lapacke_utils.h
/usr/include/openblas/openblas_config.h
/usr/lib64/libopenblas.so
/usr/lib64/libopenblaso.so
/usr/lib64/libopenblasp.so
二、配置Makefile.config
BLAS := open
# Custom (MKL/ATLAS/OpenBLAS) include and lib directories.
# Leave commented to accept the defaults for your choice of BLAS
# (which should work)!
BLAS_INCLUDE := /usr/include/openblas
BLAS_LIB := /usr/lib64/openblas
-
make clean
-
make all
三、报错
make: /usr/local/bin/bin/mexext: Command not found
目测:matlab路径没有配置正确
查找matlab安装路径
-
sudo find /usr/local -name mexext
/usr/local/MATLAB/R2014a/bin/mexext
配置Makefile.config中MATLAB路径
MATLAB_DIR := /usr/local/MATLAB/R2014a
-
Make clean
-
Make –j64 all
成功
查看caffe指向的依赖库
-
ldd build/tools/caffe
linux-vdso.so.1 => (0x00007fffff5ff000)
libcaffe.so.1.0.0-rc3 =>
libopenblas.so.0 => /usr/lib64/libopenblas.so.0 (0x00007f17b58de000)
******
libnppc.so.6.5 => /usr/local/cuda-6.5/lib64/libnppc.so.6.5 (0x00007f4d257c6000)
运行后照旧是单核。
在/usr/lib64下不仅有libopenblas.so.0(单线程版本),还有一个libopenblasp.so.0,这个就是前面软件列表中的openblas-openmp的so文件(多线程版本)
如何利用Makefile配置openblas的库文件没有搞明白。
因此,查看教程,利用CMake来指定openbals的库为多线程版本,重新编译caffe。
http://blog.csdn.net/10km/article/details/52723306
四、CMake编译caffe
于是修改OMP_NUM_THREADS或(OPENBLAS_NUM_THREADS)参数减少OpenBlas的线程数再试
-
export OMP_NUM_THREADS=4
-
export OPENBLAS_NUM_THREADS=4
-
echo $ OMP_NUM_THREADS
-
echo $ OPENBLAS_NUM_THREADS
关于OMP_NUM_THREADS和OPENBLAS_NUM_THREADS的详细用法说明参见《OpenBlas github网站》
重新运行mnist,可以看到cpu跑满4核。
但是到4核以上会报错
Segmentation fault,至今没有发现原因。