ATLAS在Fedora上的python virtualenv for numpy / scipy / scikit-learn

时间:2016-08-30 16:16:29

标签: python numpy virtualenv blas atlas

我很高兴让python在使用virtualenv时从我的发行版中找到并使用已安装的ATLAS库。

这是在Fedora 21,atlas,atlas-devel,blas,blas-devel上安装的。在virtualenv之外,命令python -c 'import numpy; numpy.show_config()'表明我有ATLAS:

atlas_3_10_blas_threads_info:
    libraries = ['tatlas']
    library_dirs = ['/usr/lib64/atlas']
    define_macros = [('HAVE_CBLAS', None), ('ATLAS_INFO', '"\\"3.10.1\\""')]
    language = c
    include_dirs = ['/usr/include']
lapack_opt_info:
    libraries = ['tatlas', 'tatlas', 'tatlas']
    library_dirs = ['/usr/lib64/atlas']
    define_macros = [('ATLAS_INFO', '"\\"3.10.1\\""')]
    language = f77
    include_dirs = ['/usr/include']
blas_opt_info:
    libraries = ['tatlas']
    library_dirs = ['/usr/lib64/atlas']
    define_macros = [('HAVE_CBLAS', None), ('ATLAS_INFO', '"\\"3.10.1\\""')]
    language = c
    include_dirs = ['/usr/include']
openblas_info:
NOT AVAILABLE
openblas_lapack_info:
NOT AVAILABLE
[...]

ls /usr/lib64/atlas/给出了:

libatlas.a   libsatlas.so    libsatlas.so.3.10  libtatlas.so.3
libcblas.so  libsatlas.so.3  libtatlas.so       libtatlas.so.3.10

我还设置了一个环境变量,以便echo $ATLAS给出

/usr/lib64/atlas/libsatlas.so

但是当我做以下事情时:

virtualenv venv
source venv/bin/activate
pip install --upgrade pip
pip install numpy
pip install scipy
pip install scikit-learn
python -c 'import numpy; numpy.show_config()'

我明白了:

lapack_opt_info:
    libraries = ['openblas', 'openblas']
    library_dirs = ['/usr/local/lib']
    define_macros = [('HAVE_CBLAS', None)]
    language = c
blas_opt_info:
    libraries = ['openblas', 'openblas']
    library_dirs = ['/usr/local/lib']
    define_macros = [('HAVE_CBLAS', None)]
    language = c
openblas_info:
    libraries = ['openblas', 'openblas']
    library_dirs = ['/usr/local/lib']
    define_macros = [('HAVE_CBLAS', None)]
    language = c
openblas_lapack_info:
    libraries = ['openblas', 'openblas']
    library_dirs = ['/usr/local/lib']
    define_macros = [('HAVE_CBLAS', None)]
    language = c
blas_mkl_info:
NOT AVAILABLE

我非常感谢帮助我们如何让numpy和scipy在virtualenv中找到并使用我的发行版中的ATLAS。

1 个答案:

答案 0 :(得分:1)

你需要告诉numpy的setup.py在哪里找到你的ATLAS库。

尝试在运行.numpy-site.cfg之前在主文件夹中创建pip install文件。 Here's此文件的模板。

您可能需要添加行

[atlas]
library_dirs = /usr/lib64/atlas
include_dirs = /usr/include

尽管如此,根据我的经验,这需要一点反复试验。

将此文件与pip install结合使用似乎可以在RHEL和Ubuntu上可靠地运行,至少在您不需要sudo的虚拟环境中。

如果这对于numpy,scipy和scikit-learn中的一个或多个失败,请考虑从源代码安装,并在运行python setup.py install之前修改源目录内的site.cfg文件。