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

发布于 2024-11-25 19:06:19 字数 1990 浏览 3 评论 0原文

theano 安装文档< /a> 声明,theano 将默认使用 numpy 中的 BLAS 库,如果“BLAS 库可作为动态加载库”。这似乎不适用于我的机器,请参阅错误消息。

  • 我如何知道 numpy BLAS 库是否可动态加载?
  • 如果 numpy BLAS 库不可动态加载,如何重新编译它们?

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

错误消息

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

附录

theano 库需要 numpy 和 BLAS 库等。我想如果你用 sudo apt-get install python- 安装它,numpy 就会附带 BLAS Ubuntu 下的 numpy python-scipy

这是 /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

这是 distutils.__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

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.

  • How do I find out, if the numpy BLAS libraries are availalbe as dynamically-loadable?
  • How do I recompile the numpy BLAS libraries, if they are not dynamically-loadable?

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

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.

This is the filelisting of /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

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

冷默言语 2024-12-02 19:06:19

下载 Python 库的 Anaconda 发行版后,我在 Ubuntu 12.04 LTS 64 位上遇到了同样的问题。将 Theano 指向包含 libblas.so 的目录就可以解决这个问题。

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

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

温柔女人霸气范 2024-12-02 19:06:19

在 ubuntu 中,在包管理器中,libblas.so 附带了 libblas3gf 包。
如果不知何故它不创建 libblas.so,而是创建 libblas.so.X,请手动创建一个符号链接,例如:

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

注意:这对我来说效果很好,但请阅读下面的评论。请记住,该软件包不会针对您的特定硬件进行优化(例如,阅读建议 ATLAS 的其他答案)。

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

层林尽染 2024-12-02 19:06:19

在您的情况下,您应该查看 /usr/lib64 并查看 libblas 等是否可用作 .so.so .X 文件。

重新编译 BLAS 并不简单,但您可以尝试为您的发行版安装相关的 ATLAS 软件包。

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.

倒数 2024-12-02 19:06:19

您的主要问题本质上是发行版维护人员是否正确安装了依赖项——对此我没有答案或解决方案。

不过,我确实有一个建议。 ATLAS 的构建并不难。获取源代码,解压,确保满足其依赖关系,然后开始配置和安装。采取步骤。依赖部分可能是该过程中最耗时的手动部分。

当然,然后你必须重新链接 numpy、theano 等。虽然我认识到这是一种痛苦(相信我,我为 Theano 和 Hannes Shulz & Andy Mueller 的 CSV 都经历过它),但你得到的好处是 BLAS 调整在您的硬件上以最佳方式运行。

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.

若言繁花未落 2024-12-02 19:06:19

如果安装了最新的足够版本的 numpy,theano 在所有情况下都将正常工作。

从这里开始,关心所使用的 blas 的唯一原因是速度。默认的 blas 非常慢。许多发行版再次编译 numpy 这个缓慢的 blas 版本。

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

较新版本的Unbuntu,done中atlas的安装是这样的,numpy将开始使用它。因此无需在 Theano 上对此进行任何更改。我不知道其他发行版是否这样做。

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

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

然后将运行速度与打印的其他比较结果进行比较。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文