2

I'm trying to speed up matrix operations using NumPy in Ubuntu 14.04 LTS (64-bit). Instead of using ATLAS (actually when I use ATLAS, there is only 1 thread which is fully running, with 7 other opened threads doing nothing, even if I specify OMP_NUM_THREADS=8 for instance. Don't know why.), I decided to give OpenBLAS a try.

I've spent hours by following several tutorials to build the source code of OpenBLAS and NumPy, e.g. [1], [2], [3], [4], and [5]. However, none of them can generate _dotblas.so after compiling NumPy, which is a critical file to speed up dot operation between matrices.

May I know if anyone has successfully built NumPy and OpenBLAS under Ubuntu 14.04? If so, may you please let me know how to do?

Thank you.


Update:

Below is basically what I summarized from the above five posts and tried in my machine:

# OpenBLAS
git clone git://github.com/xianyi/OpenBLAS
cd OpenBLAS
make FC=gfortran
sudo make PREFIX=/opt/OpenBLAS/ install
cd ..
# let the system know
sudo sh -c 'echo "/opt/OpenBLAS/lib" > /etc/ld.so.conf.d/openblas.conf'
sudo ldconfig

# Numpy
git clone https://github.com/numpy/numpy
cd numpy
vim site.cfg  # and put the following content within #### in site.cfg
####
[default]
library_dirs = /opt/OpenBLAS/lib
[atlas]
atlas_libs = openblas
library_dirs = /opt/OpenBLAS/lib
[lapack]
lapack_libs = openblas
library_dirs = /opt/OpenBLAS/lib
####
export BLAS=/opt/OpenBLAS/lib/libopenblas.a
export LAPACK=/opt/OpenBLAS/lib/libopenblas.a
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/opt/OpenBLAS/lib/
python setup.py build
sudo python setup.py install

UPDATE: The above script has been tested to work well on both Ubuntu 12.04 and 14.04 64-bit.

Community
  • 1
  • 1
mintaka
  • 982
  • 1
  • 9
  • 25

1 Answers1

3

For those who are also struggling with building NumPy with OpenBLAS, the _dotblas module is no longer available since NumPy 1.10.0, according to the Release Notes. Found from this post.

mintaka
  • 982
  • 1
  • 9
  • 25
  • Thanks for bringing this up - I've added a [new test script](https://gist.github.com/alimuldal/eb0f4eea8af331b2a890) to [my previous guide](http://stackoverflow.com/questions/11443302/compiling-numpy-with-openblas-integration/14391693#14391693) for compiling numpy against OpenBLAS – ali_m Mar 14 '15 at 19:49
  • @ali_m: Thank you for your nice guide! I've learned a lot from it previously. Actually in your guide, you didn't put `[atlas]` and `[lapack]` in the *site.cfg* file, while some others did (see some links in my post) by claiming these two are important. May you comment if `[atlas]` and `[lapack]` are really necessary? – mintaka Mar 15 '15 at 00:16
  • [ATLAS](http://math-atlas.sourceforge.net/) is an alternative BLAS implementation. That section of `site.cfg` would only be important if you wanted to use ATLAS instead of OpenBLAS (if you include both `[atlas]` and `[openblas]` sections then I think numpy prioritizes linking against OpenBLAS over ATLAS, so it wouldn't make any difference). The `[lapack]` section is also unnecessary if you're using OpenBLAS, since [a default build](https://github.com/xianyi/OpenBLAS/blob/develop/Makefile.rule#L75-L77) of OpenBLAS also includes the contents of [netlib-lapack](http://www.netlib.org/lapack/). – ali_m Mar 15 '15 at 00:23
  • @ali_m: In my post, `[atlas]` is advised to be set as `openblas`, i.e. `atlas_libs = openblas`, according to the other posts. So this attempt is actually to force NumPy to link against `openblas`, just in case it might not be when both OpenBLAS and ATLAS are installed in the machine? Under my current environment, OpenBLAS is actually prioritized, as you also mentioned. – mintaka Mar 15 '15 at 00:36
  • That's no longer necessary [as of this pull request](https://github.com/numpy/numpy/pull/3642) – ali_m Mar 15 '15 at 00:42