6

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? :)

MattDMo
  • 100,794
  • 21
  • 241
  • 231
  • 2
    I'd recommend linking it yourself, but unfortunately, MKL isn't available for free noncommercial use on OSX (it is on Linux and Windows). [Intel says this is because](http://software.intel.com/en-us/articles/performance-tools-for-software-developers-how-can-i-download-the-intel-ipp-and-intel-mkl-for-mac-os-x) "The Intel compilers deliver superb capabilities and performance leading to a very large majority of our customers choosing to purchase the Intel® C++ Composer XE 2011." The cheapest Composer variant is $129 for an academic single-user license. Thanks, Intel... – Danica Mar 27 '13 at 17:33
  • 1
    That said, [EPD](http://www.enthought.com/epd/) includes a numpy linked to MKL and has free academic licenses. It uses python 2.7, but you might be able to rip out just the MKL parts and link a numpy for 3.3 to it. I just use the system Accelerate framework, but I also run my big problems on Linux servers and use MKL there. – Danica Mar 27 '13 at 17:34
  • @Dougal - unfortunately, the [30-day free evaluation](http://www.intel.com/cd/software/products/asmo-na/eng/219690.htm) link is a 404. Any specific ideas on how to reverse-engineer EPD? I'd rather have 64-bit support if I can... – MattDMo Mar 27 '13 at 17:36
  • 1
    @Dougal: the free version of EPD does not include MKL: http://stackoverflow.com/questions/14946512/does-the-epd-free-distribution-use-mkl – Warren Weckesser Mar 27 '13 at 17:49
  • @WarrenWeckesser No, but for those of us in academia (read: have a .edu email address), there are [free academic licenses](http://www.enthought.com/products/edudownload.php) for the full version of EPD. – Danica Mar 27 '13 at 18:07
  • Some instructions here, but it would be nice if someone packaged an easy solution that was more free than EPD: https://gist.github.com/rmcgibbo/4950848 – Robert T. McGibbon May 15 '13 at 01:57
  • It's now included in the free version of [Enthought Canopy](https://www.enthought.com/products/canopy), which seems to be the replacement for [EPD](https://www.enthought.com/products/epd/). Still Python 2, though. – askewchan Oct 16 '13 at 12:45

3 Answers3

4

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

Juan
  • 3,667
  • 3
  • 28
  • 32
3

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.

abergou
  • 441
  • 2
  • 7
1

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.

MattDMo
  • 100,794
  • 21
  • 241
  • 231
Broseph
  • 1,655
  • 1
  • 18
  • 38
  • Thanks for this, I'm actually going to accept this as the answer after all these years. This is exactly what I was looking for back then - a way to install MKL-accelerated NumPy without having to build it myself, which I had to do after downloading the MKL itself from Intel. I use MacPorts for a lot of software, and I don't like the Anaconda model or distribution, so this is perfect. Cheers! – MattDMo Nov 29 '22 at 13:46