24

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

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

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

错误信息

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

附录

除了其他东西之外,theano 库还需要 numpy 和 BLAS库sudo apt-get install python-numpy python-scipy如果你在 Ubuntu 下安装 numpy,我想它会附带 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

这是的输出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
4

5 回答 5

14

下载 Python 库的 Anaconda 发行版后,我刚刚在 Ubuntu 12.04 LTS 64 位上遇到了同样的问题。将 Theano 指向包含 libblas.so 的目录会处理它。

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

于 2013-11-07T17:38:05.440 回答
3

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

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

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

于 2011-09-16T17:03:19.480 回答
2

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

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

于 2011-09-16T16:35:40.463 回答
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.

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.

于 2011-09-16T17:49:45.657 回答
1

如果安装了最新版本的 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

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

于 2011-09-16T17:41:24.100 回答