uncomplicate / neanderthal

Fast Clojure Matrix Library
http://neanderthal.uncomplicate.org
Eclipse Public License 1.0
1.06k stars 56 forks source link

Getting started on macOS Catalina 10.15.2 #83

Closed norton closed 4 years ago

norton commented 4 years ago

Are there plans to support the Intel Math Kernel Library for Deep Neural Network?

This appears (with my limited browsing) to be the least uncomplicated approach to support neanderthal on macOS Catalina 10.15.2.

There is also a homebrew formula for mkl-dnn.

Thank you

blueberry commented 4 years ago

Hi Joe,

You have been looking at the "wrong" MKL. The one you're talking about was called MKL-DNN, while the one that Neanderthal uses is MKL.

Intel's MKL stands for Math Kernel Library, and is the library of (many) optimized routines related to a wide array of math-related tasks. This is https://software.intel.com/en-us/mkl and you need to install (or copy) its binaries to be able to use Neanderhtal on the CPU. It is not open source, but it is free (to use and distribute, as in "free beer"). MKL is super stable; Intel is not going to rename it, nor does they break backward compatibility, so any recent version should work without frequent updates.

MKL-DNN is another, much more recent, library from Intel that is complementary to MKL. They unfortunately used MKL in its name, which leads to confusion with the MKL. MKL-DNN provides routines useful in deep learning, and it is NOT a replacementn or superset of MKL. Actually, it does not provide any of the BLAS/LAPACK routines that MKL does. In the first versions, MKL-DNN actually used MKL in its internals, and provided a stripped down MKL binary (which added to more confusion) .

To avoid this sort of issues, Intel renamed MKL-DNN to DNNL in mid-2019. This is the most relevant link: https://intel.github.io/mkl-dnn/index.html.

Now, DNNL has no place in Neanderthal, but in Deep Diamond https://github.com/uncomplicate/deep-diamond, a library dedicated to tensor/DNN/DL core in Clojure that I am developing, and which will also be included in the book. DNNL comes with Deep Diamond and does not require separate installation (because it is much smaller in size than MKL).

To make a short resume:

blueberry commented 4 years ago

In case anyone has issues related to Apple's new security policies that they add in each new release (I've lost track of the shenanigans they invent to force people to install only software distributed from their official store), the plain binaries can be extracted from the javacpp distribution of MKL that can be downloaded from the Maven Central repository.

Here's the most recent direct link. repo1.maven.org/maven2/org/bytedeco/mkl/2019.3-1.5/mkl-2019.3-1.5-macosx-x86_64-redist.jar

Download, rename .jar to .zip, unpack, and copy the dylib files following the official Neanderthal Getting Started Guide.

norton commented 4 years ago

I tried version 2019.5-1.5.2 and was able to require neanderthal.

This information would be helpful to add to the getting-started.html page.

Thank you.