How to make sure the numpy BLAS libraries are available as dynamically-loadable libraries?

一个人想着一个人 提交于 2019-12-02 22:13:03

After downloading the Anaconda distro of python libraries, I just encountered the same issue on Ubuntu 12.04 LTS 64-bit. Pointing Theano to the directory containing libblas.so took care of it.

$ THEANO_FLAGS=blas.ldflags="-L/usr/lib/ -lblas" python rbm.py

With ubuntu, in the package manager, libblas.so comes with the libblas3gf package. If somehow it doesn't create libblas.so, but creates libblas.so.X, manually create a symlink like:

cd /usr/lib64
sudo ln -s libblas.so.3gf libblas.so

NB: This has been working fine for me, but read the comment below though. And keep in mind this package will not be optimized to your specific hardware (read other answers that suggest ATLAS for instance).

In your case you should look in /usr/lib64 and see if libblas, etc. are available as .so or .so.X files.

Recompiling BLAS is not trivial, but you can maybe try installing the relevant ATLAS packages for your distribution.

Your main question is essentially one of whether the distro maintainers have the dependencies installing correctly or not -- and for that I don't have an answer or a solution.

However, I do have a recommendation. ATLAS isn't very hard to get to build. Get the source, unpack, ensure you've satisfied its dependencies, then kick off the configure & make steps. The dependency part is probably the most time consuming manual portion of the process.

Of course, then you have to relink numpy, theano, etc. While I recognize this is a pain (believe me, I went through it for both Theano and Hannes Shulz & Andy Mueller's CSV), the benefit you get is a BLAS tuned to run optimally on your hardware.

nouiz

If a recent enought version of numpy is installed, theano will work correctly in all case­.

From there, the only reason to care about the blas used is about speed. The default blas is very slow. Many distro compile numpy again this slow blas version.

An easy/fast way to have a faster blas implementation is to install the distro package about atlas and atlas devel. This is an optimized blas implementation.

Newer version of Unbuntu, the installation of atlas in done is such a way that numpy will start using it. So there is no need to change anything on Theano about this. I don't know if other distro do this.

The best way to check the blas that Theano use is fast or not is to time it. To do so, run this under bash:

X=`python -c "import theano;import os.path; print os.path.split(theano.__file__)[0]"`
python ${X}/misc/check_blas.py

Then compare the speed it took to run with some other comparison result printed.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!