Packaging Intel Math Kernel Libraries (mkl)

Hello nix users,

I would like to package Intel’s mkl in NixPkg, which is heavily used in machine
learning and linear algebra packages, often in place of OpenBLAS. This is a
proprietary package, with a “free to redistribute” license, provided that we
don’t modify the binary [1][2][3].

In 2018 Intel has relaxed some of their license restrictions, and the library
has been packaged for redistribution in both Debian and Anaconda. [4][5]

Intel distributes it as a large tarball download from their website, within
which there are many RPMs containing pre-built binaries for individual
platforms, and one RPM with the noarch headers.

I have a couple questions:

  1. Does the above sound reasonable in terms of licensing?
  2. Do we have any helpers around rpm2nix conversion? I currently have it working
    by extracting the rpm | cpio and moving the files where I want them to be,
    but if there’s a cleaner utility I’m all for it.
  3. Should I package all architectures? I only really need x86_86-linux and
    suspect that’s true for most users who would want this, but there are other
    RPMs available. It’d add a lot to the nix expression so I’m not sure if it’s
    worth maintaining vs. just putting a platforms = [ “x86_64-linux” ] in the meta?

I have an initial first implementation here if anyone has suggestions:
https://github.com/NixOS/nixpkgs/pull/47182

After a good bit of work and debugging, I’ve managed to get at least one package
working with this [6], so I know it’s not completely busted! That said if someone
could help test it’d be appreciated.

[1] Accelerate Fast Math with Intel® oneAPI Math Kernel Library
[2] Intel® oneAPI Math Kernel Library (oneMKL) License FAQ
[3] End User License Agreements
[4] Install Intel® AI Analytics Toolkit via Conda*
[5] Debian -- Package Search Results -- intel-mkl
[6] osqp: init at 0.4.0 · bhipple/nixpkgs@6e81fba · GitHub

3 Likes

I myself would love to help. I know that this has been done multiple times by people (most of the way) but not in the official nixpkgs branch (3 times that I can recall). Please please let’s make icc a compiler.

See Redirecting to Google Groups several repositories have been mentioned

1 Like

Thanks for packaging this! What sort of overlay should I apply to make sure that I’m using MKL as the default blas/lapack everywhere?

EDIT: Found http://ryantm.github.io/nixpkgs/using/overlays/

2 Likes

The library looks miss many things:

In my NixOS:

❯ ls -al /nix/store/wmbla2hgf1ffzmaajlij0xh10aqj24lp-mkl-2023.1.0.46342/lib/pkgconfig
Permissions Size User Date Modified Name
.r--r--r--  1.5k root  1 Jan  1970   mkl-dynamic-ilp64-gomp.pc
.r--r--r--  1.5k root  1 Jan  1970   mkl-dynamic-ilp64-iomp.pc
.r--r--r--  1.4k root  1 Jan  1970   mkl-dynamic-ilp64-seq.pc
.r--r--r--  1.5k root  1 Jan  1970   mkl-dynamic-ilp64-tbb.pc
.r--r--r--  1.5k root  1 Jan  1970   mkl-dynamic-lp64-gomp.pc
.r--r--r--  1.5k root  1 Jan  1970   mkl-dynamic-lp64-iomp.pc
.r--r--r--  1.4k root  1 Jan  1970   mkl-dynamic-lp64-seq.pc
.r--r--r--  1.4k root  1 Jan  1970   mkl-dynamic-lp64-tbb.pc

In my ArchLinux:

❯ ls -al /opt/intel/oneapi/mkl/latest/lib/pkgconfig
Permissions Size User Date Modified Name
.rw-r--r--  1.5k root 28 Apr 01:06   mkl-dynamic-ilp64-gomp.pc
.rw-r--r--  1.5k root 28 Apr 01:06   mkl-dynamic-ilp64-iomp.pc
.rw-r--r--  1.4k root 28 Apr 01:06   mkl-dynamic-ilp64-seq.pc
.rw-r--r--  1.5k root 28 Apr 01:06   mkl-dynamic-ilp64-tbb.pc
.rw-r--r--  1.4k root 28 Apr 01:06   mkl-dynamic-lp64-gomp.pc
.rw-r--r--  1.4k root 28 Apr 01:06   mkl-dynamic-lp64-iomp.pc
.rw-r--r--  1.4k root 28 Apr 01:06   mkl-dynamic-lp64-seq.pc
.rw-r--r--  1.4k root 28 Apr 01:06   mkl-dynamic-lp64-tbb.pc
.rw-r--r--  1.4k root 28 Apr 01:06   mkl-sdl.pc
.rw-r--r--  1.5k root 28 Apr 01:06   mkl-static-ilp64-gomp.pc
.rw-r--r--  1.5k root 28 Apr 01:06   mkl-static-ilp64-iomp.pc
.rw-r--r--  1.5k root 28 Apr 01:06   mkl-static-ilp64-seq.pc
.rw-r--r--  1.5k root 28 Apr 01:06   mkl-static-ilp64-tbb.pc
.rw-r--r--  1.5k root 28 Apr 01:06   mkl-static-lp64-gomp.pc
.rw-r--r--  1.5k root 28 Apr 01:06   mkl-static-lp64-iomp.pc
.rw-r--r--  1.5k root 28 Apr 01:06   mkl-static-lp64-seq.pc
.rw-r--r--  1.5k root 28 Apr 01:06   mkl-static-lp64-tbb.pc

Where is mkl-sdl.pc in NixOS?

Please please let’s make icc a compiler.

In my ArchLinux:

❯ pacman -Qo /opt/intel/oneapi/compiler/2023.1.0/linux/bin/icx
/opt/intel/oneapi/compiler/2023.1.0/linux/bin/icx is owned by intel-oneapi-dpcpp-cpp 2023.1.0-1

In my nixOS:

❯ nix-locate bin/icx

Not any package provide icx and icpx.