Numpy-MKL for OS X

Question:

I love being able to use Christoph Gohlke’s numpy-MKL version of NumPy linked to Intel’s Math Kernel Library on Windows. However, I have been unable to find a similar version for OS X, preferably NumPy 1.7 linked for Python 3.3 on Mountain Lion. Does anyone know where this might be obtained?

EDIT:

So after a bit of hunting I found this link to evaluate Intel’s Composer XE2013 studios for C++ and Fortran (both of which contain the MKL), as well as a tutorial on building NumPy and SciPy with it, so this will serve for the present. However, the question remains – is there a frequently-updated archive for OS X similar to Christoph Gohlke’s? If not, why not? 🙂

Asked By: MattDMo

||

Answers:

I know that this is an older question, but in case it comes up for someone who is searching: I would recommend trying out anaconda. For $29.00 they have an add-on that includes mkl optimized numpy + scipy.

Answered By: abergou

Intel has release their MKL under a community license, which is free, with limited technical support. Currently MKL under the Community License is available for Linux and Windows, and it is expected they will provide a version for Mac OS X soon.

https://software.intel.com/en-us/comment/1839012

In one of their recent webinars, I asked for their plans for a Mac OS X MKL under the community license. They say it is coming soon.

Update 2:

Continuum provides Anaconda Python with Intel MKL included for all platforms.

https://www.anaconda.com/blog/developer-blog/anaconda-25-release-now-mkl-optimizations/

Intel even makes it easy to compile and link against the MKL from the Anaconda Python distribution.

https://software.intel.com/en-us/articles/using-intel-distribution-for-python-with-anaconda

Update:

It now appears that Intel has their own version of Python that they are providing to beta testers.

https://software.intel.com/en-us/forums/intel-distribution-for-python/topic/581593

Answered By: Juan

MacPorts seems to have recently added an MKL variant to their NumPy port (as well as to SciPy and PyTorch). Tested on my 16” MacBook Pro 2019 with 2.4GHz 8-core Intel Core i9 and macOS Ventura 13.0.1, Numpy with MKL is significantly faster than Numpy with the Accelerate framework, which is another fast replacement for OpenBLAS that is built into macOS. I tested using this code which I got from Puget Systems:

import numpy as np
import time
n = 20000
A = np.random.randn(n,n).astype('float64')
B = np.random.randn(n,n).astype('float64')
start_time = time.time()
nrm = np.linalg.norm(A@B)
print(" took {} seconds ".format(time.time() - start_time))
print(" norm = ",nrm)

The result of my testing is that Numpy with mkl took ~47 seconds while Numpy with accelerate took ~66 seconds. Accelerate also used more threads.

To install this with MacPorts you first have to install MacPorts, then run sudo port install py310-numpy -openblas +mkl in the terminal.

Answered By: Broseph