1. Compiling OpenBlas
$ git clone git://github.com/xianyi/OpenBLAS
$ cd OpenBLAS && make FC=gfortran
$ sudo make PREFIX=/opt/OpenBLAS install
$ sudo ldconfig
2. Compiling numpy and scipy with OpenBlas
We need to re-compile numpy from the source to ensure numpy uses OpenBlas
$ git clone https://github.com/numpy/numpy
$ cd numpy
$ cp site.cfg.example site.cfg
$ vim
site.cfg
Look for [openblas] in the site.cfg and uncomment these lines
....
[openblas]
libraries = openblas
library_dirs = /opt/OpenBLAS/lib
include_dirs = /opt/OpenBLAS/include
....
Then setup the configuration file and build numpy
$ python setup.py config
$ python setup.py build && python setup.py install
Repeat the same thing (2) for scipy
3. Compiling caffe using OpenBlasbuild and install numpy
Copy libopenblas.a to /usr/lib and /usr/local/lib (otherwise caffe gives compile error: usr/lib/ld: cannot find -lopenblas)
$ cp /opt/OpenBlas/lib/libopenblas.a /usr/lib /usr/local/lib/
$ cp /opt/OpenBlas/lib/libopenblas.so* /usr/lib /usr/local/lib
In Makefile.config set
$ BLAS := open
Under the caffe directory
$ make all
$ make pycaffe
No comments:
Post a Comment