使用virtualenv时,我努力让python从我的发行版中查找和使用已安装的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


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

最佳答案

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

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

您可能需要添加行

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


虽然,根据我的经验,这需要反复试验。

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

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

关于python - 在Fedora中的python virtualenv上使用ATLAS进行numpy/scipy/scikit-learn,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/39232482/

10-12 22:52