如何确保numpy BLAS库作为动态加载库可用?

时间:2022-07-17 04:07:47

The theano installation documentation states, that theano will as a default use the BLAS libraries from numpy, if the "BLAS libraries are available as dynamically-loadable libraries". This seems not to be working on my machine, see error message.

theano安装文档指出,如果“BLAS库可以作为动态加载库使用”,theano将默认使用numpy的BLAS库。这似乎在我的机器上不起作用,请参见错误消息。

  • How do I find out, if the numpy BLAS libraries are availalbe as dynamically-loadable?
  • 我如何知道,如果numpy BLAS库可用作动态加载?
  • How do I recompile the numpy BLAS libraries, if they are not dynamically-loadable?
  • 如果numpy BLAS库不是动态加载的,那么如何重新编译它们呢?

Please indicate, if you would need more information!

如果您需要更多的信息,请注明!

Error message

错误消息

We did not found a dynamic library into the library_dir of the library we use for blas. If you use ATLAS, make sure to compile it with dynamics library. /usr/bin/ld: cannot find -lblas

我们在用于blas的库的library_dir中没有找到动态库。如果您使用ATLAS,请确保使用dynamics库对其进行编译。/usr/bin/ld:找不到-lblas

Appendix

附录

The theano library needs among other things numpy and a BLAS library. I figured numpy comes with BLAS if you install it with sudo apt-get install python-numpy python-scipy under Ubuntu.

theano图书馆需要numpy和BLAS图书馆。我觉得numpy附带了BLAS,如果你在Ubuntu中安装了sudo apt-get安装python-numpy python-scipy。

This is the filelisting of /usr/lib64/python2.6/dist-packages/scipy/lib/blas

这是/usr/lib64/python2.6/dist-packages/scipy/lib/blas的文件列表

cblas.so  info.py   __init__.py   scons_support.py   setup.py     
fblas.so  info.pyc  __init__.pyc  scons_support.pyc  setup.pyc  
setupscons.py  test
setupscons.pyc

This is the output of distutils.__config__.show() is as follows

这是distutil .__config .show()的输出,如下所示

blas_info:
    libraries = ['blas']
    library_dirs = ['/usr/lib64']
    language = f77

lapack_info:
    libraries = ['lapack']
    library_dirs = ['/usr/lib64']
    language = f77

atlas_threads_info:
  NOT AVAILABLE

blas_opt_info:
    libraries = ['blas']
    library_dirs = ['/usr/lib64']
    language = f77
    define_macros = [('NO_ATLAS_INFO', 1)]

atlas_blas_threads_info:
  NOT AVAILABLE

lapack_opt_info:
    libraries = ['lapack', 'blas']
    library_dirs = ['/usr/lib64']
    language = f77
    define_macros = [('NO_ATLAS_INFO', 1)]

atlas_info:
  NOT AVAILABLE

lapack_mkl_info:
  NOT AVAILABLE

blas_mkl_info:
  NOT AVAILABLE

atlas_blas_info:
  NOT AVAILABLE

mkl_info:
  NOT AVAILABLE

5 个解决方案

#1


11  

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.

在下载python库的Anaconda发行版之后,我刚刚在Ubuntu 12.04 LTS 64位上遇到了同样的问题。将Theano指向包含libblas的目录。所以我很小心。

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

美元THEANO_FLAGS =布拉斯特区。ldflags =“- l / usr / lib / -lblas”python rbm.py

#2


3  

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:

使用ubuntu,在包管理器libblas中。libblas3gf包也是如此。如果它不创建libblas。但创建libblas.so。X,手工创建一个符号链接,如:

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).

NB:这对我来说很好,但是请阅读下面的评论。请记住,这个包不会针对您的特定硬件进行优化(请阅读其他建议ATLAS的答案)。

#3


2  

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

在您的例子中,您应该查看/usr/lib64,看看libblas等是否可用。X文件。

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

重新编译BLAS并不容易,但是您可以尝试为您的发行版安装相关的ATLAS包。

#4


1  

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

如果多方最近版本的安装numpy,在所有情况下­theano将正常工作。

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.

从那时起,关心使用的blas的唯一理由就是速度。默认的blas非常缓慢。许多发行版再次编译numpy这个缓慢的blas版本。

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.

要实现更快的blas实现,一个简单/快速的方法是安装关于atlas和atlas devel的发行版包。这是一个优化的blas实现。

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.

新版本的Unbuntu,在done中安装atlas是为了让numpy能够开始使用它。所以没有必要对Theano做任何改变。我不知道其他发行版是否会这样做。

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:

检查Theano是否使用blas的最好方法是计时。为此,请在bash下运行此命令:

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

导入theano;导入os.path;打印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.

然后比较一下与其他比较结果打印出来的速度。

#5


1  

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.

然而,我有一个建议。阿特拉斯不是很难建造的。获取源代码,解包,确保您已经满足了它的依赖项,然后启动配置和make步骤。依赖项部分可能是流程中最耗时的手工部分。

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.

当然,您必须重新链接numpy、theano等。尽管我认识到这是一种痛苦(相信我,我在theano和Hannes Shulz & Andy Mueller的CSV中都遇到过这种情况),但您得到的好处是在您的硬件上运行最优的BLAS。

#1


11  

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.

在下载python库的Anaconda发行版之后,我刚刚在Ubuntu 12.04 LTS 64位上遇到了同样的问题。将Theano指向包含libblas的目录。所以我很小心。

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

美元THEANO_FLAGS =布拉斯特区。ldflags =“- l / usr / lib / -lblas”python rbm.py

#2


3  

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:

使用ubuntu,在包管理器libblas中。libblas3gf包也是如此。如果它不创建libblas。但创建libblas.so。X,手工创建一个符号链接,如:

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).

NB:这对我来说很好,但是请阅读下面的评论。请记住,这个包不会针对您的特定硬件进行优化(请阅读其他建议ATLAS的答案)。

#3


2  

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

在您的例子中,您应该查看/usr/lib64,看看libblas等是否可用。X文件。

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

重新编译BLAS并不容易,但是您可以尝试为您的发行版安装相关的ATLAS包。

#4


1  

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

如果多方最近版本的安装numpy,在所有情况下­theano将正常工作。

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.

从那时起,关心使用的blas的唯一理由就是速度。默认的blas非常缓慢。许多发行版再次编译numpy这个缓慢的blas版本。

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.

要实现更快的blas实现,一个简单/快速的方法是安装关于atlas和atlas devel的发行版包。这是一个优化的blas实现。

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.

新版本的Unbuntu,在done中安装atlas是为了让numpy能够开始使用它。所以没有必要对Theano做任何改变。我不知道其他发行版是否会这样做。

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:

检查Theano是否使用blas的最好方法是计时。为此,请在bash下运行此命令:

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

导入theano;导入os.path;打印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.

然后比较一下与其他比较结果打印出来的速度。

#5


1  

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.

然而,我有一个建议。阿特拉斯不是很难建造的。获取源代码,解包,确保您已经满足了它的依赖项,然后启动配置和make步骤。依赖项部分可能是流程中最耗时的手工部分。

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.

当然,您必须重新链接numpy、theano等。尽管我认识到这是一种痛苦(相信我,我在theano和Hannes Shulz & Andy Mueller的CSV中都遇到过这种情况),但您得到的好处是在您的硬件上运行最优的BLAS。