# Yet another failed attempt to build julia with MKL

**URL:** https://discourse.julialang.org/t/yet-another-failed-attempt-to-build-julia-with-mkl/7327
**Category:** General Usage
**Created:** [November 26, 2017, 10:48pm UTC](https://discourse.julialang.org/t/yet-another-failed-attempt-to-build-julia-with-mkl/7327 "2017-11-26T22:48:47Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![navidcy](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/navidcy/32/2750_2.png) [@navidcy](https://discourse.julialang.org/u/navidcy)
#### Post date: [November 26, 2017, 10:48pm UTC](https://discourse.julialang.org/t/yet-another-failed-attempt-to-build-julia-with-mkl/7327/1 "2017-11-26T22:48:48Z")

</div>

I’ve reached bottom and despair…

I’ve tried MANY times to build julia with MKL. I’ve done all sorts of gimmicks and tricks people mention here at GitHub and all over the internet. Repetitive failure each time more or less with a different error.

My machine:

```julia
MBP 15-inch Early 2017
2.9GHz Inter Core i7
macOS High Sierra 10.13.1

```

with:  
`MKL version 2018 Update 1`

I document here my latest attempt:  
`.zshrc`:

```julia
source /opt/intel/mkl/bin/mklvars.sh intel64 ilp64
export TBBROOT=fdsljkfds

```

`Make.user`:

```julia
  USEICC = 0
  USEIFC = 0
  USE_INTEL_MKL = 1
  USE_INTEL_MKL_FFT = 1
  USE_INTEL_LIBM = 1
  MKLROOT = /opt/intel/compilers_and_libraries/mac/mkl
  LIBM = /opt/intel/compilers_and_libraries/mac/lib -limf

```

Then I removed the `/intel64` as well as some if statements from `Make.inc` as described at #18167. My `Make.inc` reads now:

```julia
 988 # Intel libraries
 989
 990 ifeq ($(USE_INTEL_LIBM), 1)
 991 USE_SYSTEM_LIBM := 1
 992 LIBM := -L$(MKLROOT)/../compiler/lib -limf
 993 LIBMNAME := libimf
 994 endif
 995
 996 ifeq ($(USE_INTEL_MKL), 1)
 997 # ifeq ($(USE_BLAS64), 1)
 998 export MKL_INTERFACE_LAYER := ILP64
 999 MKLLIB := $(MKLROOT)/lib
1000 # else
1001 # MKLLIB := $(MKLROOT)/lib/ia32
1002 # endif
1003 USE_SYSTEM_BLAS:=1
1004 USE_SYSTEM_LAPACK:=1
1005 # ifeq ($(OS), WINNT)
1006 # LIBBLASNAME := mkl_rt
1007 # LIBLAPACKNAME := mkl_rt
1008 # # work around libtool issue with arpack
1009 # MKL_LDFLAGS := -L$(MKLLIB) -Wl,-lmkl_rt
1010 # else
1011 LIBBLASNAME := libmkl_rt
1012 LIBLAPACKNAME := libmkl_rt
1013 MKL_LDFLAGS := -L$(MKLLIB) -lmkl_rt
1014 # endif
1015 ifneq ($(strip $(MKLLIB)),)
1016 ifeq ($(OS), Linux)
1017 RPATH_MKL := -Wl,-rpath,$(MKLLIB)
1018 RPATH += $(RPATH_MKL)
1019 MKL_LDFLAGS += $(RPATH_MKL)
1020 endif
1021 endif
1022 LIBBLAS := $(MKL_LDFLAGS)
1023 LIBLAPACK := $(MKL_LDFLAGS)
1024 endif
1025
1026 ifeq ($(USE_INTEL_MKL_FFT), 1)
1027 USE_SYSTEM_FFTW := 1
1028 LIBFFTWNAME := libmkl_rt
1029 LIBFFTWFNAME := libmkl_rt
1030 endif

```

I create folder `usr/lib` and link files:

```julia
 ln -s /opt/intel/lib/libimf.dylib usr/lib/libimf.dylib
 ln -s /opt/intel/mkl/lib/libmkl_rt.dylib usr/lib/libmkl_rt.dylib
 ln -s /opt/intel/lib/libintlc.dylib usr/lib/libintlc.dylib        

```

Then, running `make` gives (this time):

```julia
  CC libcurl_la-connect.lo
/Users/navid/julia/deps/srccache/curl-7.53.1/lib/connect.c:1087:12: error: 'connectx' is only available on macOS
      10.11 or newer [-Werror,-Wunguarded-availability]
      rc = connectx(sockfd, &endpoints, SAE_ASSOCID_ANY,
           ^ ~~~~~~~
/usr/include/sys/socket.h:713:5: note: 'connectx' has been explicitly marked partial here
int connectx(int, const sa_endpoints_t *, sae_associd_t, unsigned int,
    ^
/Users/navid/julia/deps/srccache/curl-7.53.1/lib/connect.c:1087:12: note: enclose 'connectx' in a
      __builtin_available check to silence this warning
      rc = connectx(sockfd, &endpoints, SAE_ASSOCID_ANY,
           ^ ~~~~~~~
1 error generated.
make[4]: *** [libcurl_la-connect.lo] Error 1
make[3]: *** [all] Error 2
make[2]: *** [all-recursive] Error 1
make[1]: *** [scratch/curl-7.53.1/build-compiled] Error 2
make: *** [julia-deps] Error 2

```

---

<div class="post-metadata">

### Author: ![andreasnoack](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/andreasnoack/32/27_2.png) [@andreasnoack](https://discourse.julialang.org/u/andreasnoack)
#### Post date: [November 27, 2017, 12:09pm UTC](https://discourse.julialang.org/t/yet-another-failed-attempt-to-build-julia-with-mkl/7327/2 "2017-11-27T12:09:17Z")

</div>

Which version/commit of Julia are you trying to build?

---

<div class="post-metadata">

### Author: ![Ken-B](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ken-b/32/1780_2.png) [@Ken-B](https://discourse.julialang.org/u/Ken-B)
#### Post date: [December 24, 2017, 9:24pm UTC](https://discourse.julialang.org/t/yet-another-failed-attempt-to-build-julia-with-mkl/7327/3 "2017-12-24T21:24:23Z")

</div>

I can replicate with the latest julia master on osx 10.13.2.  
(` git rev-parse HEAD` gives me `b385693ceb66458849dee5267fc56e051e517d95`)

It would be much appreciated if someone who actually managed to build with MKL on osx could document this step by step. I’m willing to assist, of course.

Meanwhile, I just saw that the free JuliaPro is now available with MKL. Makes me wonder if the julialang one might also be distributed with MKL?

For the curious, [it seems that](https://twitter.com/ChrisRackauckas/status/942805494183313408) “MKL destroys OpenBLAS in julia”, that’s why people keep trying to build it.

---

<div class="post-metadata">

### Author: ![ChrisRackauckas](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/chrisrackauckas/32/77_2.png) [@ChrisRackauckas](https://discourse.julialang.org/u/ChrisRackauckas)
#### Post date: [December 24, 2017, 9:39pm UTC](https://discourse.julialang.org/t/yet-another-failed-attempt-to-build-julia-with-mkl/7327/4 "2017-12-24T21:39:40Z")

</div>

> [@Ken-B](#):
>
> For the curious, it seems that “MKL destroys OpenBLAS in julia”, that’s why people keep trying to build it.

Destroys was probably a little strong, but yes there are some cases where it’s much faster with not many the opposite 😛.

> [@Ken-B](#):
>
> Makes me wonder if the julialang one might also be distributed with MKL?

It’s mentioned in that thread that I believe it can’t due to licensing issues (because there’s still some GPL in the standard libraries?). Someone else can probably make that more precise.

---

<div class="post-metadata">

### Author: ![Elrod](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/elrod/32/22461_2.png) [@Elrod](https://discourse.julialang.org/u/Elrod)
#### Post date: [December 24, 2017, 11:03pm UTC](https://discourse.julialang.org/t/yet-another-failed-attempt-to-build-julia-with-mkl/7327/5 "2017-12-24T23:03:24Z")

</div>

I did a few tests with an old AMD processor, and OpenBLAS often outperformed MKL on it. Intel does warn that their software is only optimized for Intel hardware.  
I have since upgraded to a computer with a Ryzen processor. Ryzen is apparently a lot like Haswell, so perhaps MKL will perform better on it. But I wouldn’t be surprised if MKL doesn’t recognize Ryzen and thus falls back to generic kernels instead of Haswell.

I could try in a few days.

---

<div class="post-metadata">

### Author: ![ChrisRackauckas](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/chrisrackauckas/32/77_2.png) [@ChrisRackauckas](https://discourse.julialang.org/u/ChrisRackauckas)
#### Post date: [December 25, 2017, 12:30am UTC](https://discourse.julialang.org/t/yet-another-failed-attempt-to-build-julia-with-mkl/7327/6 "2017-12-25T00:30:43Z")

</div>

Just to throw some older tests in here:

> [@Benchmark MATLAB & Julia for Matrix Operations](https://discourse.julialang.org/t/benchmark-matlab-julia-for-matrix-operations/2000/92):
>
> To add another datapoint, here are the results on a 32-core node on our cluster, with and without threading and comparing OpenBLAS and MKL: [https://github.com/barche/julia-blas-benchmarks/blob/master/BenchmarkResults.ipynb](https://github.com/barche/julia-blas-benchmarks/blob/master/BenchmarkResults.ipynb) I also reran the HPL linpack test, here are the results: Standard HPL OpenBLAS, 32 MPI processes on a single node: 757 Gflops Standard HPL MKL, 32 MPI processes on a single node: 788 Gflops Intel HPL MKL, 32 MPI processes on a single node: 814 Gflops Intel HPL MKL, 2 MP…

[[Album] imgur.com ![](https://global.discourse-cdn.com/julialang/original/3X/1/3/132ad823d5c63d5e31e6a57c17700c6d85f930fa.jpeg "imgur.com") ](https://imgur.com/a/rBOo8)

The biggest difference seems to be if you solve a bunch of linear systems. This is noticeable for solving stiff ODEs BTW.

---

<div class="post-metadata">

### Author: ![Yifan\_Liu](https://avatars.discourse-cdn.com/v4/letter/y/4da419/32.png) [@Yifan\_Liu](https://discourse.julialang.org/u/Yifan_Liu)
#### Post date: [December 25, 2017, 1:26am UTC](https://discourse.julialang.org/t/yet-another-failed-attempt-to-build-julia-with-mkl/7327/7 "2017-12-25T01:26:21Z")

</div>

What matrix operation are you using? For most jobs the time advantage of MKL is not that noticeable, especially if you are using non-intel core. Eigen3 and Juia can handle most matrix operations for me.
