I have a numpy
install and it shows no BLAS backend available:
(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)]
I can do pip install mkl
but still the same output as above. How can I link numpy
to use MKL as BLAS / LAPACK backend?
You can try using in intel python. Create an environment with intel python and required packages like intel-mkl, intel-numpy etc.
conda create -n <env-name> intelpython3_full python=3.7.3
conda activate <env_name>
pip install mkl
pip install intel-numpy
and try importing numpy and running np.show_config()
Refer : https://pypi.org/project/mkl/ https://pypi.org/project/intel-numpy/
The better way is to install the Intel base Toolkit and source the variables. Intel mkl and intel python is available with the kit. You just need to source the environment variables
source <basekit-installation-directory>/setvars.sh
Installation guide : https://software.intel.com/content/www/us/en/develop/documentation/installation-guide-for-intel-oneapi-toolkits-linux/top.html
You can also try the suggestion provided by Jerome Richard – try setting the LD_LIBRARY_PATH and LD_PRELOAD path to the mkl library .so file. Refer : https://software.intel.com/content/www/us/en/develop/articles/optimizing-without-breaking-a-sweat.html
NumPy has to be compiled against mkl
, so you can't just switch BLAS/LAPACK libraries at runtime by installing mkl
. Instead you will need to install a NumPy version that has been compiled against the MKL libraries.
Since the other answer is somewhat outdated (Intel Python no longer has current NumPy versions), let me provide a list of current options here:
Here I'm using pixi
as package manager, but similar results can be obtained using conda
or mamba
.
anaconda
(linked against mkl
by default):
pixi init -c anaconda
pixi add numpy
conda-forge
(requires libblas=*=*mkl
and "liblapack=*=*mkl"
)
pixi init -c conda-forge
pixi add numpy "libblas=*=*mkl" "liblapack=*=*mkl"
pip install /path/to/numpy_wheel.whl
pip install numpy --extra-index-url https://urob.github.io/numpy-mkl
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With