My question: How do I get Python to use my own compiled OpenBLAS version?
Background
The Theano install guide suggests that one should test that the BLAS library components associated are correctly optimized through these commands:
THEANO_FLAGS=floatX=float32,device=cpu python `python -c "import os, theano; print os.path.dirname(theano.__file__)"`/misc/check_blas.py
THEANO_FLAGS=floatX=float32,device=gpu python `python -c "import os, theano; print os.path.dirname(theano.__file__)"`/misc/check_blas.py
The results are:
Card: GTX 770
Results on CPU 0.62s and GPU 0.11s
Not sure whether these results were good I decided to compare different libraries as done in this post. As scientific computing requires every possible speed-up this seemed like a good idea.
Compiling and installing OpenBLAS from GitHub
In order to test the latest version I've:
- cloned the git
git clone https://github.com/xianyi/OpenBLAS.git
- entered the directory and made a
make TARGET=HASWELL
(the TARGET is not really necessary as it detects it automatically) - followed by
make PREFIX=/opt/OpenBLAS install
. - copied the files under lib (libopenblas.a libopenblas_haswellp-r0.2.14.a libopenblas_haswellp-r0.2.14.so libopenblas.so libopenblas.so.0) to
/usr/lib/openblas-haswell_cstm/
- added an alternative through
sudo update-alternatives --install /usr/lib/libblas.so.3 libblas.so.3 /usr/lib/openblas-haswell_cstm/libopenblas.so.0 30
Unfortunately this gives an error:
$ sudo update-alternatives --config libblas.so.3
There are 4 choices for the alternative libblas.so.3 (providing /usr/lib/libblas.so.3).
Selection Path Priority Status
------------------------------------------------------------
0 /usr/lib/openblas-base/libblas.so.3 40 auto mode
* 1 /usr/lib/atlas-base/atlas/libblas.so.3 35 manual mode
2 /usr/lib/libblas/libblas.so.3 10 manual mode
3 /usr/lib/openblas-base/libblas.so.3 40 manual mode
4 /usr/lib/openblas-haswell_cstm/libopenblas.so.0 30 manual mode
Press enter to keep the current choice[*], or type selection number: 4
update-alternatives: using /usr/lib/openblas-haswell_cstm/libopenblas.so.0 to provide /usr/lib/libblas.so.3 (libblas.so.3) in manual mode
max@MaxLin:~/tutorials$ python
Python 2.7.8 (default, Oct 20 2014, 15:05:19)
[GCC 4.9.1] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import numpy
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/python2.7/dist-packages/numpy/__init__.py", line 153, in <module>
from . import add_newdocs
File "/usr/lib/python2.7/dist-packages/numpy/add_newdocs.py", line 13, in <module>
from numpy.lib import add_newdoc
File "/usr/lib/python2.7/dist-packages/numpy/lib/__init__.py", line 18, in <module>
from .polynomial import *
File "/usr/lib/python2.7/dist-packages/numpy/lib/polynomial.py", line 19, in <module>
from numpy.linalg import eigvals, lstsq, inv
File "/usr/lib/python2.7/dist-packages/numpy/linalg/__init__.py", line 50, in <module>
from .linalg import *
File "/usr/lib/python2.7/dist-packages/numpy/linalg/linalg.py", line 29, in <module>
from numpy.linalg import lapack_lite, _umath_linalg
ImportError: /usr/lib/liblapack.so.3: undefined symbol: gotoblas
I'm not sure if this has to do with the compiled version not being a .so.3 version. I've tried using the libopenblas_haswellp-r0.2.14.so and the libopenblas.so created by the make
but it has no effect on the error.