The Math Kernel Library (mkl), a high-performance matrix library made by Intel, is now available for free. I will explain how to make this available from numpy. The target is Linux (I am Ubuntu 14.04).
Click "click here now to register and download" on the following site.
https://software.intel.com/en-us/articles/free_mkl
Enter your name, email address, company name, etc. You will receive a registration email, which you can follow to download. There is no Mac version. It's about 1GB. Make a note of the registration key that you will need during installation.
I downloaded l_mkl_11.3.0.109.tgz
Extract the downloaded file. There is `ʻinstall.shin it, so execute it. The installation destination is
/ opt / intel`` by default, and you will be prompted to enter the registration key on the way, so enter it. (
If you don't want to use interactive, modify the following part of the silent.cfg
file in the unzipped directory.
ACCEPT_EULA=accept
ACTIVATION_SERIAL_NUMBER=XXXX-XXXXXXXX
ACTIVATION_TYPE=serial_number
You can install it from the command line only by running ʻinstall.sh -s silent.cfg`.
Put LD_LIBRARY_PATH
in / opt / intel / mkl / lib / intel64
.
For the settings when installing numpy, go to ~ / .numpy-site.cfg
. The template for this file is in the source.
https://github.com/numpy/numpy/blob/master/site.cfg.example
Modify the file and keep it in your home directory. The contents are as follows.
[mkl]
library_dirs = /opt/intel/mkl/lib/intel64/
include_dirs = /opt/intel/mkl/include
mkl_libs = mkl_rt
lapack_libs =
For details, refer to the following site. https://software.intel.com/en-us/articles/numpyscipy-with-intel-mkl
In this state, pip install --no-binary: all: numpy
will install numpy using mkl without permission. If numpy is originally included, uninstall it once.
You can see which matrix library you are using by looking at numpy.show_config ()
. If you run Chainer as an example, it seems that it is running at about 1.5 times faster than OpenBLAS.
$ python
>>> import numpy
>>> numpy.show_config()
lapack_opt_info:
libraries = ['mkl_rt', 'pthread']
library_dirs = ['/opt/intel/mkl/lib/intel64/']
define_macros = [('SCIPY_MKL_H', None)]
include_dirs = ['/opt/intel/mkl/include']
blas_opt_info:
libraries = ['mkl_rt', 'pthread']
library_dirs = ['/opt/intel/mkl/lib/intel64/']
define_macros = [('SCIPY_MKL_H', None)]
include_dirs = ['/opt/intel/mkl/include']
openblas_lapack_info:
NOT AVAILABLE
lapack_mkl_info:
libraries = ['mkl_rt', 'pthread']
library_dirs = ['/opt/intel/mkl/lib/intel64/']
define_macros = [('SCIPY_MKL_H', None)]
include_dirs = ['/opt/intel/mkl/include']
blas_mkl_info:
libraries = ['mkl_rt', 'pthread']
library_dirs = ['/opt/intel/mkl/lib/intel64/']
define_macros = [('SCIPY_MKL_H', None)]
include_dirs = ['/opt/intel/mkl/include']
mkl_info:
libraries = ['mkl_rt', 'pthread']
library_dirs = ['/opt/intel/mkl/lib/intel64/']
define_macros = [('SCIPY_MKL_H', None)]
include_dirs = ['/opt/intel/mkl/include']
Recommended Posts