Intel Mkl Windows building

Can anyone give me a step by step tutorial on how I can build Julia to use Intel MKL?

Edit: if you read this later follow my steps as I said here:

To Install:

julia>]add https://github.com/JuliaComputing/MKL.jl

After building which takes some time restart Julia.

If you get the Intel MKL FATAL ERROR: Cannot load mkl_intel_thread.dll. error, that means the required dlls are not on the path. You need to add the location that it was installed to your path. On windows usually that is C:\Users\%USERNAME%\.julia\packages\MKL\36eeJ\deps\usr\bin . You can add it to your windows path by running the following command in Windows cmd:

setx PATH=%PATH%;C:\Users\%USERNAME%\.julia\packages\MKL\36eeJ\deps\usr\bin

To Check Installation:

Once the install has completed, you’ll have

julia> using LinearAlgebra julia> BLAS.vendor() :mkl

P.S: I am surprised that Julia doesn’t provide native support for Intel MKL. The software is already free to redistribute. (Intel® oneAPI Math Kernel Library (oneMKL) License FAQ)

old question

Here it says to set your environment. How should I do that on windows?
https://github.com/JuliaLang/julia/blob/master/doc/build/build.md#intel-mkl
Also, by Make.user does it mean ‘Make.inc’?

I followed these until before building:
https://github.com/JuliaLang/julia/blob/master/doc/build/windows.md

1 Like

Have you seen MKL.jl?

2 Likes

Yes. That has not been updated for several months, and apparently it has some issues in it.

Julia allows building from source and changing BLAS to Intel MKL.

On Windows it’s fairly easy to change to the MKL by hand (or at least it was last time I tried). I’ll see if I can find my old instructions when I get back to my windows machine on Monday.

3 Likes

Does it really work?

If there are issues, I would love to know. We are trying to make sure it is a functional setup using it. At this point, the key is that you need to package compile it into the image, which works well.

The other issues (eg arpack and suitsparse incompatibility) are known, but the issue is the mkl itself, rather than that specific package. Ie building with mkl has the same problems, as far as I understand

Except from lack of documentation regarding how to run MKL.jl, my main problem with that was the issue regarding REPL delay because of lack of precompilation information compared to official releases after more than 6 months now: Improve REPL latency · Issue #1 · JuliaLinearAlgebra/MKL.jl · GitHub
I added a comment to the issue but from no one responding I assumed it is discontinued.

He is out of town now, but maybe @arnavsood can point us in the right direction on the installation /package compilation steps. The loss of arpack and suitesparse functionality will take more time, but there is progress.

1 Like

Can’t you just do using MKL in your sysimage script and compile that to fix the problem?

1 Like

I am not sure. I don’t know how to use this repository or fix its issues. If you guys know please submit a pull request to update the repository.
I believe this repository should also provide prebuilt releases for the convenience of users (especially because JuliaPro doesn’t provide MKL anymore).

What issues? It seems ]add MKL and then using MKL works fine on Windows? I didn’t rebuild my sysimage for it but you’d do it just like how you’d do it for any other package.

2 Likes

By issues I mean the delay in REPL.
I am gonna try that.

The delay in the REPL isn’t that much - it just means that it takes a second or two longer to start when first running Julia.

Just to explain what I think MKL.jl does:

add MKL downloads the Intel binaries, modifies one of the files in your Julia install to tell it to use the MKL, and then rebuilds your sysimg. After doing this you are always using the MKL (even without the using statement). Uninstalling the package won’t remove the MKL (except maybe the Intel binaries - bad things might happen since Julia still looks for them).

using MKL just seems to set some threading options. I’m not sure this is entirely necessary (I never used to bother).

The only thing that needs to happen to get a fast REPL start-up is for an extra file to be included during the sysimg rebuild. (The problem is that file isn’t included in the standard Julia install.)

3 Likes

]add MKL
result:

ERROR: The following package names could not be resolved:
 * MKL (not found in project, manifest or registry)
Please specify by known `name=uuid`

Try

]add https://github.com/JuliaComputing/MKL.jl

Hopefully that works - don’t have my laptop to check.

1 Like

This took some time to complete, and seemed to do something.

(v1.1) pkg> add https://github.com/JuliaComputing/MKL.jl
  Updating registry at `C:\Users\username\.julia\registries\General`
  Updating git-repo `https://github.com/JuliaRegistries/General.git`
   Cloning git-repo `https://github.com/JuliaComputing/MKL.jl`
  Updating git-repo `https://github.com/JuliaComputing/MKL.jl` Resolving package versions...
 Installed HTTPClient ────── v0.2.1
 Installed Libz ──────────── v1.0.0
 Installed WinRPM ────────── v0.4.2
 Installed LibCURL ───────── v0.5.1
 Installed TextWrap ──────── v0.3.0
 Installed BufferedStreams ─ v1.0.0
 Installed PackageCompiler ─ v0.6.3
 Installed WebIO ─────────── v0.8.4
 Installed LibExpat ──────── v0.5.0
 Installed BinDeps ───────── v0.8.10
 Installed ArgParse ──────── v0.6.2
  Updating `C:\Users\username\.julia\environments\v1.1\Project.toml`
  [33e6dc65] + MKL v0.0.0 #master (https://github.com/JuliaComputing/MKL.jl)
  Updating `C:\Users\username\.julia\environments\v1.1\Manifest.toml`
  [c7e460c6] + ArgParse v0.6.2
  [9e28174c] + BinDeps v0.8.10
  [e1450e63] + BufferedStreams v1.0.0
  [0862f596] + HTTPClient v0.2.1
  [b27032c2] + LibCURL v0.5.1
  [522f3ed2] + LibExpat v0.5.0
  [2ec943e9] + Libz v1.0.0
  [33e6dc65] + MKL v0.0.0 #master (https://github.com/JuliaComputing/MKL.jl)
  [9b87118b] + PackageCompiler v0.6.3
  [b718987f] + TextWrap v0.3.0
  [0f1e0344] ↑ WebIO v0.8.1 ⇒ v0.8.4
  [c17dfb99] + WinRPM v0.4.2
  Building WebIO ──────────→ `C:\Users\username\.julia\packages\WebIO\kk2q1\deps\build.log`
  Building LibCURL ────────→ `C:\Users\username\.julia\packages\LibCURL\teHPG\deps\build.log`
  Building WinRPM ─────────→ `C:\Users\username\.julia\packages\WinRPM\Y9QdZ\deps\build.log`
  Building PackageCompiler → `C:\Users\username\.julia\packages\PackageCompiler\oT98U\deps\build.log`
  Building MKL ────────────→ `C:\Users\username\.julia\packages\MKL\36eeJ\deps\build.log`

However, when I ran this code after it still says it is openBlas.

using LinearAlgebra
 BLAS.vendor()

and now when I restart my Julia this is the result:
Intel MKL FATAL ERROR: Cannot load mkl_intel_thread.dll.

Could you explain what do you mean by: The loss of arpack and suitesparse functionality will take more time, but there is progress.?

1 Like

As far as I understand it, if you use mkl.jl and package compile it into your system image, it works great for almost all of base and is a solid experience.

The current issue is that other packages which assume that openblas is installed need to be patched to support using mkl for any dense calculations.

In particular, Sparse Arrays · The Julia Language uses suitesparse as matrix factorization lfor linear solves (I think) and arpack.jl currently requires openblas (necessary for eigs).People are trying to work through the binary builder issues to make usage with mkl seamless,but I would guess later in July

1 Like

Yes, this what should happen; the new sysimg will only take effect once Julia is restarted.

That means the required dlls are not on the Windows path. You need to add the location that it was installed to your path - for me that is C:\Users\dawbarton\.julia\packages\MKL\36eeJ\deps\usr\bin. After that it should all work (at least it does for me!).

3 Likes

Thank you! It finally worked. I added that folder to my user Path in environment variables, and it worked!

julia> using LinearAlgebra
julia>  BLAS.vendor()
:mkl