我安装了numpy
,它显示没有可用的BLAS后端:
(pyrepoux) bash-4.2$ python
Python 3.7.3 | packaged by conda-forge | (default, Dec 6 2019, 08:54:18)
[GCC 7.3.0] :: Anaconda, Inc. on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import numpy as np
>>> np.show_config()
blas_mkl_info:
NOT AVAILABLE
blis_info:
NOT AVAILABLE
openblas_info:
libraries = ['openblas', 'openblas']
library_dirs = ['/usr/local/lib']
language = c
define_macros = [('HAVE_CBLAS', None)]
blas_opt_info:
libraries = ['openblas', 'openblas']
library_dirs = ['/usr/local/lib']
language = c
define_macros = [('HAVE_CBLAS', None)]
lapack_mkl_info:
NOT AVAILABLE
openblas_lapack_info:
libraries = ['openblas', 'openblas']
library_dirs = ['/usr/local/lib']
language = c
define_macros = [('HAVE_CBLAS', None)]
lapack_opt_info:
libraries = ['openblas', 'openblas']
library_dirs = ['/usr/local/lib']
language = c
define_macros = [('HAVE_CBLAS', None)]
我可以做pip install mkl
,但输出仍然和上面一样。如何链接numpy
以使用MKL作为BLAS/LAPACK后端?
您可以尝试在intel python中使用。使用intel python和所需的包(如intel mkl、intel numpy等(创建一个环境。
conda create -n <env-name> intelpython3_full python=3.7.3
conda activate <env_name>
pip install mkl
pip install intel-numpy
并尝试导入numpy并运行np.show_config()
参考:https://pypi.org/project/mkl/https://pypi.org/project/intel-numpy/
更好的方法是安装英特尔基本工具包并获取变量。该套件提供Intel mkl和Intel python。您只需要获取环境变量
source <basekit-installation-directory>/setvars.sh
安装指南:https://software.intel.com/content/www/us/en/develop/documentation/installation-guide-for-intel-oneapi-toolkits-linux/top.html
您也可以尝试Jerome Richard提供的建议——尝试设置mkl库.so文件的LD_LIBRARY_PATH和LD_PRELOAD路径。参考:https://software.intel.com/content/www/us/en/develop/articles/optimizing-without-breaking-a-sweat.html