Answers:
方法numpy.show_config()
(或numpy.__config__.show()
)输出有关在构建时收集的链接的信息。我的输出看起来像这样。我认为这意味着我正在使用Mac OS随附的BLAS / LAPACK。
>>> import numpy as np
>>> np.show_config()
lapack_opt_info:
extra_link_args = ['-Wl,-framework', '-Wl,Accelerate']
extra_compile_args = ['-msse3']
define_macros = [('NO_ATLAS_INFO', 3)]
blas_opt_info:
extra_link_args = ['-Wl,-framework', '-Wl,Accelerate']
extra_compile_args = ['-msse3', '-I/System/Library/Frameworks/vecLib.framework/Headers']
define_macros = [('NO_ATLAS_INFO', 3)]
lapack_opt_info
意味着numpy与lapack相连?
numpy.show_config()
,由于缺少下划线,它可能是公共API函数。但是它没有在线记录,也没有文档字符串,因此很难找到它也就不足为奇了。希望他们能解决这个问题。
您要搜索的是: 系统信息
我用地图集编译了numpy / scipy,我可以使用以下命令进行检查:
import numpy.distutils.system_info as sysinfo
sysinfo.get_info('atlas')
查看文档以获取更多命令。
sysinfo.get_info('atlas')
对我 什么也没有sysinfo.get_info('blas')
返回{'include_dirs': ['/usr/local/include', '/usr/include', '/opt/local/include', '/usr/local/Cellar/python/2.7.13/Frameworks/Python.framework/Versions/2.7/include'], 'libraries': ['blas', 'blas'], 'library_dirs': ['/usr/lib']}
,但是返回 并sysinfo.get_info('lapack')
返回 {'language': 'f77', 'libraries': ['lapack', 'lapack'], 'library_dirs': ['/usr/lib']}
是什么意思?
由于它使用动态加载的版本,因此您可以执行以下操作:
$ ldd anyoftheCmodules.so
anyoftheCmodules.so
例如,numpy/core/_dotblas.so
链接到的位置在哪里libblas.so
。
numpy/core/_dotblas.so
怎么办?(请参见以下关于talonmies答案的评论)
.so
文件。只需在NumPy目录中搜索(例如,使用find /path/to/numpy -name "*.so"
)。其中的几个(例如_dotblas.so
,lapack_lite.so
在Ubuntu的预编译版本下)使用BLAS / LAPACK
_dotblas.so
不再存在numpy的1.10和更新的,但你可以检查的联动multiarray.so
,而不是
您可以使用链接加载器依赖项工具查看构建的C级钩子组件,并查看它们是否对所选择的blas和lapack有外部依赖关系。我现在不在Linux盒子附近,但是在OS X机器上,您可以在保存安装的site-packages目录中执行此操作:
$ otool -L numpy/core/_dotblas.so
numpy/core/_dotblas.so:
/System/Library/Frameworks/Accelerate.framework/Versions/A/Accelerate (compatibility version 1.0.0, current version 4.0.0)
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 125.2.0)
/System/Library/Frameworks/vecLib.framework/Versions/A/vecLib (compatibility version 1.0.0, current version 268.0.1)
$ otool -L scipy/linalg/flapack.so
scipy/linalg/flapack.so (architecture i386):
/System/Library/Frameworks/Accelerate.framework/Versions/A/Accelerate (compatibility version 1.0.0, current version 4.0.0)
/usr/local/lib/libgcc_s.1.dylib (compatibility version 1.0.0, current version 1.0.0)
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 111.1.4)
/System/Library/Frameworks/vecLib.framework/Versions/A/vecLib (compatibility version 1.0.0, current version 242.0.0)
scipy/linalg/flapack.so (architecture ppc):
/System/Library/Frameworks/Accelerate.framework/Versions/A/Accelerate (compatibility version 1.0.0, current version 4.0.0)
/usr/local/lib/libgcc_s.1.dylib (compatibility version 1.0.0, current version 1.0.0)
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 111.1.4)
$ otool -L scipy/linalg/fblas.so
scipy/linalg/fblas.so (architecture i386):
/System/Library/Frameworks/Accelerate.framework/Versions/A/Accelerate (compatibility version 1.0.0, current version 4.0.0)
/usr/local/lib/libgcc_s.1.dylib (compatibility version 1.0.0, current version 1.0.0)
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 111.1.4)
/System/Library/Frameworks/vecLib.framework/Versions/A/vecLib (compatibility version 1.0.0, current version 242.0.0)
scipy/linalg/fblas.so (architecture ppc):
/System/Library/Frameworks/Accelerate.framework/Versions/A/Accelerate (compatibility version 1.0.0, current version 4.0.0)
/usr/local/lib/libgcc_s.1.dylib (compatibility version 1.0.0, current version 1.0.0)
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 111.1.4)
代替ldd
代替otool
一个GNU / Linux系统上,你应该得到你所需要的答案。
numpy/core/_dotblas.so
怎么办?(请参阅Ricardos回答下方的评论)
_dotblas.so
哪一个接口来包装用于构建发行版的内容。在Windows上将称为_dotblas.pyd
,但功能相同。
_dotblas.so
只有在使用中的[atlas]
部分site.cfg
(和启用了CBLAS的BLAS库)中才能构建。因此,即使您没有使用ATLAS,也应该使用它(除非使用Intel MKL时有专门的部分)。
_dotblas.so
不再存在numpy的1.10和更新的,但你可以检查的联动multiarray.so
,而不是
您可以使用以下命令显示BLAS,LAPACK,MKL链接show_config()
:
import numpy as np
np.show_config()
对我来说输出:
mkl_info:
libraries = ['mkl_rt', 'pthread']
library_dirs = ['/my/environment/path/lib']
define_macros = [('SCIPY_MKL_H', None), ('HAVE_CBLAS', None)]
include_dirs = ['/my/environment/path/include']
blas_mkl_info:
libraries = ['mkl_rt', 'pthread']
library_dirs = ['/my/environment/path/lib']
define_macros = [('SCIPY_MKL_H', None), ('HAVE_CBLAS', None)]
include_dirs = ['/my/environment/path/include']
blas_opt_info:
libraries = ['mkl_rt', 'pthread']
library_dirs = ['/my/environment/path/lib']
define_macros = [('SCIPY_MKL_H', None), ('HAVE_CBLAS', None)]
include_dirs = ['/my/environment/path/include']
lapack_mkl_info:
libraries = ['mkl_rt', 'pthread']
library_dirs = ['/my/environment/path/lib']
define_macros = [('SCIPY_MKL_H', None), ('HAVE_CBLAS', None)]
include_dirs = ['/my/environment/path/include']
lapack_opt_info:
libraries = ['mkl_rt', 'pthread']
library_dirs = ['/my/environment/path/lib']
define_macros = [('SCIPY_MKL_H', None), ('HAVE_CBLAS', None)]
include_dirs = ['/my/environment/path/include']
('HAVE_CBLAS', None)]
?
numpy.__config__
实际上应该是一个公共API。尽管如此,达沃斯特还是赢得了这一回合。