Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Install Scipy with MKL through PIP

I am using PIP to install Scipy with MKL to accelerate the performance. My OS is Ubuntu 64 bit. Using the solution from this question, I create a file .numpy-site.cfg

[mkl]
library_dirs=/opt/intel/composer_xe_2013_sp1/mkl/lib/intel64/
include_dirs=/opt/intel/mkl/include/
mkl_libs=mkl_intel_lp64,mkl_intel_thread,mkl_core,mkl_rt
lapack_libs=

This file helps me to install Numpy with MKL successfully. However, using the same above file, installing Scipy prompts the error

ImportError: libmkl_rt.so: cannot open shared object file: No such file or directory

I also use

export LD_LIBRARY_PATH=/opt/intel/composer_xe_2013_sp1/mkl/lib/intel64

but the problem is still the same.

Anyone know how to fix this problem? I don't want to install Scipy manually so anyone give me some hints to fix it.

like image 636
tndoan Avatar asked Feb 24 '14 15:02

tndoan


People also ask

Can I install SciPy with pip?

Method 1: Using pip to install Scipy Package Step 1: Install the latest Python3 in MacOS. Step 2: Check if pip3 and python3 are correctly installed. Step 3: Upgrade your pip to avoid errors during installation. Step 4: Enter the following command to install Scipy using pip3.

Does SciPy use MKL?

On other Intel-based systems, there are several freely available Python distributions with versions of NumPy and SciPy that are linked against the Intel Math Kernel Library (MKL).

How do I install a SciPy module in Python?

Type and run pip install scipy in the command prompt. This will use the Python Package index, and install the core SciPy packages on your computer. You can also install other core packages like Numpy and Matplotlib by using the pip install numpy and pip install matplotlib commands.


3 Answers

Intel has been publishing wheels of packages like Numpy, Scipy and Scikit-learn to PyPI. These wheels have been built while linking against Intel MKL, and include various optimizations.

If you want Scipy built with Intel MKL:

#Remove existing Numpy and/or Scipy:
pip uninstall numpy scipy -y
#Install scipy built with Intel MKL:
pip install intel-scipy

More information available here

like image 179
t7t0t0t7t Avatar answered Oct 06 '22 00:10

t7t0t0t7t


2 years have passed since this question was asked.

There are now numpy/scipy wheels for linux that use a openblas compiled for avx2, so you can get much better performance without building packages. You may need to upgrade pip to get it to install the wheel:

pip install --upgrade pip
pip install numpy scipy

If you want MKL, then you can install Anaconda or Intel Distribution for Python. They use conda instead of pip to manage packages, but they are free and distribute packages that contain all the dependences, including MKL.

like image 36
rscohn2 Avatar answered Oct 06 '22 00:10

rscohn2


I have Win10 64Bit with Python 3.6.2 i have installed scipy through http://www.lfd.uci.edu/~gohlke/pythonlibs/#scipy

I followed following steps :

  • Step 1: Uninstall if you have any previous version of numpy, pip uninstall numpy
  • Step 2 : Download numpy‑1.13.1+mkl‑cp36‑cp36m‑win_amd64.whl with MKL(Math Kernel Library) from below link, http://www.lfd.uci.edu/~gohlke/pythonlibs/#numpy
  • Step 3: copy downloaded file into another location and launch command prompt from that location.
  • Step 4: run this command, pip install -U numpy-1.13.1+mkl-cp36-cp36m-win_amd64.whl
  • Step 5: Now Download scipy library from, http://www.lfd.uci.edu/~gohlke/pythonlibs/#scipy
  • Step 6: Copy downloaded file into same location in which numpy is copied.
  • Step 7: In CMD prompt run this cmd, pip install scipy-0.19.1-cp36-cp36m-win_amd64.whl

Done!

like image 41
Prabhu Avatar answered Oct 05 '22 22:10

Prabhu