Ubuntu20.04 Numpy MKL install

/ Python

Ubuntu20.04LTS python + Numpy + MKL quick install.

install libmkl-dev

$ sudo apt install libmkl-dev
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following additional packages will be installed:
  libmkl-avx libmkl-avx2 libmkl-avx512 libmkl-avx512-mic libmkl-computational-dev libmkl-core libmkl-def libmkl-gf-ilp64 libmkl-gf-lp64 libmkl-gnu-thread libmkl-intel-ilp64
  libmkl-intel-lp64 libmkl-intel-thread libmkl-interface-dev libmkl-locale libmkl-mc libmkl-mc3 libmkl-meta-computational libmkl-meta-interface libmkl-meta-threading libmkl-pgi-thread
  libmkl-rt libmkl-sequential libmkl-tbb-thread libmkl-threading-dev libmkl-vml-avx libmkl-vml-avx2 libmkl-vml-avx512 libmkl-vml-avx512-mic libmkl-vml-cmpt libmkl-vml-def libmkl-vml-mc
  libmkl-vml-mc2 libmkl-vml-mc3 libomp-10-dev libomp-dev libomp5-10
Suggested packages:
  intel-mkl-doc libomp-10-doc
The following NEW packages will be installed:
  libmkl-avx libmkl-avx2 libmkl-avx512 libmkl-avx512-mic libmkl-computational-dev libmkl-core libmkl-def libmkl-dev libmkl-gf-ilp64 libmkl-gf-lp64 libmkl-gnu-thread libmkl-intel-ilp64
  libmkl-intel-lp64 libmkl-intel-thread libmkl-interface-dev libmkl-locale libmkl-mc libmkl-mc3 libmkl-meta-computational libmkl-meta-interface libmkl-meta-threading libmkl-pgi-thread
  libmkl-rt libmkl-sequential libmkl-tbb-thread libmkl-threading-dev libmkl-vml-avx libmkl-vml-avx2 libmkl-vml-avx512 libmkl-vml-avx512-mic libmkl-vml-cmpt libmkl-vml-def libmkl-vml-mc
  libmkl-vml-mc2 libmkl-vml-mc3 libomp-10-dev libomp-dev libomp5-10
0 upgraded, 38 newly installed, 0 to remove and 8 not upgraded.
Need to get 271 MB of archives.
After this operation, 1,715 MB of additional disk space will be used.
Do you want to continue? [Y/n] Y

Console dialogue is shown for the first time you install libmkl-dev.

build and install numpy/scipy

Edit ~/.numpy-cite.cfg below

[mkl]
brary_dirs = /opt/intel/mkl/lib/intel64
include_dirs = /opt/intel/mkl/include
mkl_libs = mkl_rt
lapack_libs =

and run pip command below

python3 -m pip install --force-reinstall --no-binary :all: numpy
python3 -m pip install --force-reinstall --no-binary :all: scipy

numpy

Defaulting to user installation because normal site-packages is not writeable
Collecting numpy
  Downloading numpy-1.22.2.zip (11.4 MB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 11.4/11.4 MB 3.7 MB/s eta 0:00:00
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
  Preparing metadata (pyproject.toml) ... done
Building wheels for collected packages: numpy
  Building wheel for numpy (pyproject.toml) ... done
  Created wheel for numpy: filename=numpy-1.22.2-cp38-cp38-linux_x86_64.whl size=18956398 sha256=52ef09ead2d269459359da608754987cbf21bbb23fff01041b5bace087b125c6
  Stored in directory: /home/user/.cache/pip/wheels/81/9b/bf/44ebc6eedd6aea553cfb41f3830116f23fbc3782bef4842ef6
Successfully built numpy
Installing collected packages: numpy
Successfully installed numpy-1.22.2

scipy

Defaulting to user installation because normal site-packages is not writeable
Collecting scipy
  Downloading scipy-1.8.0.tar.gz (38.3 MB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 38.3/38.3 MB 3.2 MB/s eta 0:00:00
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
  Preparing metadata (pyproject.toml) ... done
Collecting numpy<1.25.0,>=1.17.3
  Using cached numpy-1.22.2.zip (11.4 MB)
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
  Preparing metadata (pyproject.toml) ... done
Building wheels for collected packages: scipy, numpy
  Building wheel for scipy (pyproject.toml) ... done
  Created wheel for scipy: filename=scipy-1.8.0-cp38-cp38-linux_x86_64.whl size=85643170 sha256=93c7469d8af938588ddbf67efe790a3a2bfdf261bb315356bda78512ee7bb445
  Stored in directory: /home/user/.cache/pip/wheels/33/70/8e/daed2f67c09e2151e68994119ed0243d220609a31bb3754452
  Building wheel for numpy (pyproject.toml) ... done
  Created wheel for numpy: filename=numpy-1.22.2-cp38-cp38-linux_x86_64.whl size=18956028 sha256=f9f5bbc295d650c567dc052383b19d61001ee8377b1d53d8e24df210b8ccebd3
  Stored in directory: /home/user/.cache/pip/wheels/81/9b/bf/44ebc6eedd6aea553cfb41f3830116f23fbc3782bef4842ef6
Successfully built scipy numpy
Installing collected packages: numpy, scipy
  Attempting uninstall: numpy
    Found existing installation: numpy 1.22.2
    Uninstalling numpy-1.22.2:
      Successfully uninstalled numpy-1.22.2
  Attempting uninstall: scipy
    Found existing installation: scipy 1.8.0
    Uninstalling scipy-1.8.0:
      Successfully uninstalled scipy-1.8.0
Successfully installed numpy-1.22.2 scipy-1.8.0

Finally, you check show_config() function in numpy/scipy

import numpy, scipy
numpy.show_config()
scipy.show_config()