Attention conservation notice: Improved (?) writings to self about some mundane configuration process I somehow can't get right completely, filled up with fluffy words.
I recently set up an Arch Linux computer and found out that my original description for numpy/scipy with OpenBLAS here is way too convoluted: OpenBLAS fixed the missing symbols issue that resulted in the unnecessary workaround in my original post. It turns out, however, that getting everything running on Ubuntu 12.04 is still more work than on Arch Linux. Update June 3rd, 2013: deleted some non-sense paragraphs.
apt-get
preparations for 12.04
sudo apt-get install git python-dev gfortran
You probably have these installed anyway.
OpenBLAS
git clone git://github.com/xianyi/OpenBLAS
Change into the new directory, then
make FC=gfortran
sudo make PREFIX=/usr/local/ install
The latest lapack release is downloaded, compiled and integreated into OpenBLAS automatically. Ready for the python part!
Numpy
git clone https://github.com/numpy/numpy
Usually one is interested in OpenBLAS because of its fast matrix-matrix multiplication. Whether numpy has a fast dot
function is indicated by the presence of core/_dotblas.so
. However, currently (June 2013) this file is only build, if site.cfg
has an [atlas]
section (also see here and here). There is an interesting thread here with a link to this fix in order to add support for using OpenBLAS for the _dotblas
function. However, right now do vi site.cfg
and:
[default]
library_dirs = /usr/local/lib
[atlas]
atlas_libs = openblas
library_dirs = /usr/local/lib
[lapack]
lapack_libs = openblas
library_dirs = /usr/local/lib
Without the [lapack]
section there were problems with installing scipy
later on. Additionally:
export BLAS=/usr/local/lib/libopenblas.a
export LAPACK=/usr/local/lib/libopenblas.a
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib/
Check the detected configuration with python setup.py config
. You should see several ATLAS_INFO
paired with None
. If there is something like 3.8.2
instead of None
then you have an ATLAS install somewhere on your system and numpy won't use OpenBLAS. Get rid of this install (e.g. via apt-get purge
) and rerun the config
command. If ATLAS_INFO
is completely missing then numpy couldn't find your libopenblas*
libraries — you need to check all previous steps again. Now:
python setup.py build
If you look into build/numpy/core
, the file _dotblas.so
should be available.
sudo python setup.py install
installs a system wide numpy that uses OpenBLAS for dot products. This test produces
FAST BLAS
version: 1.8.0.dev-3f10c36
maxint: 9223372036854775807
dot: 0.162246799469
You can change the number of cores OpenBLAS utilizes via OPENBLAS_NUM_THREADS
, e.g. export OPENBLAS_NUM_THREADS=2
results in
:::bash
FAST BLAS
version: 1.8.0.dev-3f10c36
maxint: 9223372036854775807
dot: 0.0949754238129 sec
Scipy
git clone https://github.com/scipy/scipy
Scipy can be installed without any workaround:
python setup.py build
sudo python setup.py install
Make sure that in your sudo
command the variables BLAS
, LAPACK
and LD_LIBRARY_PATH
are correctly set, as shown above! This test script (it has some room for improvement, though ...) works on my machine after the system wide install:
cholesky: 0.080588388443 sec
svd: 1.13443040848 sec
Finally, if you feel good enough (and do a pip install nose
), you can run nose tests via
python -c "import numpy; numpy.test(verbose=2)"
python -c "import scipy; scipy.test(verbose=2)"
(Note: I didn't!). Comments, corrections, pointers, etc. are more than welcome.