1.caffe 上OpenBLAS的安裝使用
BLAS是一個數學函數接口標準,有很多個實現。按照Caffe官方ubuntu的安裝文檔默認安裝的是ATLAS。這個版本的BLAS不能利用多核CPU,我們將其換為OpenBLAS,可以利用多核CPU并行計算,加快Caffe的分類速度。
源代碼安裝配置OpenBLAS
-git代碼到本地并安裝
git clone https://github.com/xianyi/OpenBLAS.git
cd OpenBLAS
make -j4
make install
-修改Caffe的Makefile.config
BLAS_INCLUDE := /opt/OpenBLAS/include
BLAS_LIB := /opt/OpenBLAS/lib
-caffe重新make
make clean
make pycaffe
make all -j6
make test && runtest
在caffe安裝好后,編譯時要指定Makefile.config
# BLAS choice:
# atlas for ATLAS (default)
# mkl for MKL
# open for OpenBlas
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/local/OpenBlas/include
BLAS_LIB := /usr/local/OpenBlas/lib
在runtest時會報一個錯::error while loading shared libraries: libopenblas.so.0: cannot open shared object file: No such file or directory.
解決方法:在/usr/lib/下建立一個 軟鏈接將 libopenblas.so.0指向/openbls安裝目錄/lib/ libopenblas.so.0
sudo ln -s /opt/OpenBLAS/lib/libopenblas.so.0 /usr/lib/libopenblas.so.0