如何检查numpy / scipy中的blas / lapack链接?
基于这个步骤,我基于blas和lapack来或多或less地构build了我的numpy / scipy环境。
当我完成后,我该如何检查,我的numpy / scipy函数是否确实使用了先前构build的blas / lapackfunction?
你正在寻找的是这样的: 系统信息
我编译numpy / scipy与地图集,我可以检查:
import numpy.distutils.system_info as sysinfo sysinfo.get_info('atlas')
检查文档以获取更多命令。
方法numpy.__config__.show()
输出在构build时收集的关于链接的信息。 我的输出看起来像这样。 我认为这意味着我正在使用Mac OS附带的BLAS / LAPACK。
>>>import numpy as np >>>np.__config__.show() 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)]
因为它使用dynamic加载的版本,所以你可以这样做:
$ ldd anyoftheCmodules.so
例如, numpy/core/_dotblas.so
,其链接到libblas.so
。
您可以使用链接加载器依赖项工具来查看您的构build的C级钩子组件,并查看它们是否具有外部依赖关系的选项。 我现在不在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)
在gnu / Linux系统中用ldd
代替otool
,你应该得到你需要的答案。