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.

1 Answer 1

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.

5
  • Thanks for bringing this up - I've added a new test script to my previous guide for compiling numpy against OpenBLAS
    – ali_m
    Commented Mar 14, 2015 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
    Commented Mar 15, 2015 at 0:16
  • ATLAS 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 of OpenBLAS also includes the contents of netlib-lapack.
    – ali_m
    Commented Mar 15, 2015 at 0: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
    Commented Mar 15, 2015 at 0:36
  • That's no longer necessary as of this pull request
    – ali_m
    Commented Mar 15, 2015 at 0:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.