Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use numpy with OpenBLAS instead of Atlas in Ubuntu?

I have looked for an easy way to install/compile Numpy with OpenBLAS but didn't find an easy answer. All the documentation I have seen takes too much knowledge as granted for someone like me who is not used to compile software. There are two packages in Ubuntu related to OpenBLAS : libopenblas-base and libopenblas-dev. Once they are installed, what should I do to install Numpy again with them? Thanks!

Note that when these OpenBLAS packages are installed, Numpy doesn't work anymore: it can't be imported: ImportError: /usr/lib/liblapack.so.3gf: undefined symbol: ATL_chemv. The problem occurs as well when installing Theano with their website instructions for Ubuntu.

This was noticed here already.

like image 812
PierreE Avatar asked Sep 03 '12 13:09

PierreE


People also ask

Does NumPy use OpenBLAS?

NumPy does not require any external linear algebra libraries to be installed. However, if these are available, NumPy's setup script can detect them and use them for building. A number of different LAPACK library setups can be used, including optimized LAPACK libraries such as OpenBLAS or MKL.


2 Answers

Run sudo update-alternatives --all and set liblapack.so.3gf to /usr/lib/lapack/liblapack.so.3gf

like image 157
PierreE Avatar answered Oct 04 '22 21:10

PierreE


To add to the accepted answer (of using update-alternatives), the reason for this is because OpenBlas is not compatible with the Atlas version of Lapack. For each of the Blas and Lapack versions:

  1. Default Blas + Default Lapack => OK
  2. OpenBlas + Default Lapack => OK
  3. Atlas-Blas + Default Lapack => OK
  4. Atlas-Blas + Atlas-Lapack => OK
  5. OpenBlas + Atlas-Lapack => ERROR! (The following case here.)

This is from both personal experience (with the exact same issue) and realizing why such a combination wasn't mentioned in this comparison blog.

By the way, you can just find the necessary files in /etc/alternatives/, usually with a filename starting with lib*. For each one do sudo update-alternatives --config <filename>. For example, do to following:

  • sudo update-alternatives --config libblas.so
  • sudo update-alternatives --config libblas.so.3

to change the Blas version.

like image 21
Jamie Tsao Avatar answered Oct 04 '22 20:10

Jamie Tsao