Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot load libmkl_intel_thread.dylib #315

Closed
crondonm opened this issue Oct 2, 2017 · 42 comments
Closed

Cannot load libmkl_intel_thread.dylib #315

crondonm opened this issue Oct 2, 2017 · 42 comments

Comments

@crondonm
Copy link

crondonm commented Oct 2, 2017

Hi, I'm new to Julia and I am still learning. I am on MacOS 10.13 (High Sierra) and using Julia 0.6, and installed anaconda3 with python 3.6.2. Every time I run PyPlot like this:
using PyPlot
plot(rand(10))

I got the following error:

Intel MKL FATAL ERROR: Cannot load libmkl_intel_thread.dylib
Julia has stopped: 2

I have tried everything. I uninstalled Julia and Python, I switched back and forth between the private Conda version from PyCall and Python 3.6. Moreover, I plot directly from Python using matlibplot it works fine. The problem seems to be Julia. I ran out of ideas.

Any help is appreciated.

Carlos

@iamed2
Copy link

iamed2 commented Oct 3, 2017

@willtebbutt is also experiencing this, with Python 2.7 installed with Conda.jl, and El Capitan.

@stevengj
Copy link
Member

stevengj commented Oct 3, 2017

Possibly a conflict between the BLAS libraries linked to Julia and those linked to NumPy (which is used by Matplotlib). Are you using the standard Julia binary, built with OpenBLAS, or a Julia binary linked with MKL?

@iamed2
Copy link

iamed2 commented Oct 3, 2017

Will was using the binaries (OpenBLAS). We're currently building Julia from source on his machine to see if we get the same problem.

@jonalm
Copy link

jonalm commented Oct 3, 2017

I'm having the same issue on OSX Sierra.

julia> using PyPlot
julia> plot(rand(10))
Intel MKL FATAL ERROR: Cannot load libmkl_intel_thread.dylib.

For what its worth:

My julia version is Version 0.6.0 (2017-06-19 13:05 UTC), installed from the v0.6.0 branch, using make -j 4, and I believe the python version PyPlot tries to use, is whatever PyCall installs by default.

julia> Pkg.build("PyPlot")
INFO: Building Conda
INFO: Building PyCall
INFO: PyCall is using /Users/jon.alm.eriksen/.julia/v0.6/Conda/deps/usr/bin/python (Python 2.7.13) at /Users/jon.alm.eriksen/.julia/v0.6/Conda/deps/usr/bin/python, libpython = /Users/jon.alm.eriksen/.julia/v0.6/Conda/deps/usr/lib/libpython2.7
INFO: /Users/jon.alm.eriksen/.julia/v0.6/PyCall/deps/deps.jl has not changed
INFO: /Users/jon.alm.eriksen/.julia/v0.6/PyCall/deps/PYTHON has not changed

@stevengj
Copy link
Member

stevengj commented Oct 3, 2017

Is there a libmkl_intel_thread.dylib anywhere in ~/.julia/v0.6/Conda/deps/usr? Maybe the anaconda packagers didn't link things correctly so that it is just not finding the path?

@jonalm
Copy link

jonalm commented Oct 3, 2017

@stevengj I don't know if this is expected? It looks like there are three of them.

~/opt/julia > find ~/.julia/v0.6/Conda/deps/usr -name "libmkl_intel_thread.dylib"
/Users/jon.alm.eriksen/.julia/v0.6/Conda/deps/usr/lib/libmkl_intel_thread.dylib
/Users/jon.alm.eriksen/.julia/v0.6/Conda/deps/usr/pkgs/mkl-2017.0.1-0/lib/libmkl_intel_thread.dylib
/Users/jon.alm.eriksen/.julia/v0.6/Conda/deps/usr/pkgs/mkl-2018.0.0-hc285769_4/lib/libmkl_intel_thread.dylib

I don't know how this linking work, but is there someway to manually point to the dylib file?

Curiously, this seems to work:

~/opt/julia > /Users/jon.alm.eriksen/.julia/v0.6/Conda/deps/usr/bin/python
Python 2.7.13 |Continuum Analytics, Inc.| (default, Dec 20 2016, 23:05:08)
[GCC 4.2.1 Compatible Apple LLVM 6.0 (clang-600.0.57)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
Anaconda is brought to you by Continuum Analytics.
Please check out: http://continuum.io/thanks and https://anaconda.org
>>> import matplotlib
>>> import matplotlib.pyplot as plt
>>> plt.plot([1,2,3])
[<matplotlib.lines.Line2D object at 0x112375ad0>]

@stevengj
Copy link
Member

stevengj commented Oct 4, 2017

Setting LD_LIBRARY_PATH explicitly works around the problem, i.e.export LD_LIBRARY_PATH=$HOME/.julia/v0.6/Conda/deps/usr/lib before launching Julia, and then it works for me.

This seems like a problem with Anaconda. The library paths are set up correctly if you launch the python executable, apparently, but not if you load libpython from another program (as we do in Julia).

@willtebbutt
Copy link

This solution also works for me. Thanks!

@jonalm
Copy link

jonalm commented Oct 4, 2017

Works for me too. Greatly appreciated suggestion @stevengj Thanks.

@crondonm
Copy link
Author

crondonm commented Oct 4, 2017

It also works for me. Thank you very much!

@flamesofmoon
Copy link

Thank you very much @stevengj Works for me as well. I have struggled for two days!

@flamesofmoon
Copy link

@stevengj do you know how to set that forever? Cause every time I run Julia I have to type that command which is troublesome. Thanks a lot!

@stevengj
Copy link
Member

stevengj commented Oct 6, 2017

@flamesofmoon , you can put it in your ~/.profile file.

Hopefully, we'll soon have better fix. If nothing else, as I mentioned in ContinuumIO/anaconda-issues#6423, I can add manual dlopen calls in PyPlot and PyCall. But hopefully we can get this fixed in Anaconda.

@flamesofmoon
Copy link

@stevengj Thank you! I still have the following questions:

But I don't know what it means by putting it in some designated directory. Also, I don't have the directory ~/.profile. Could you please give me the bash command cause I just started to use terminal.

@stevengj
Copy link
Member

stevengj commented Oct 6, 2017

echo "export LD_LIBRARY_PATH=$HOME/.julia/v0.6/Conda/deps/usr/lib" >> ~/.profile

then the next time you re-launch the terminal it will be set.

@flamesofmoon
Copy link

@stevengj Thank you for the reply!

I don't know why, but this time your command doesn't work on my laptop. With or without resetting the terminal, I get Intel MKL FATAL ERROR: Cannot load libmkl_intel_thread.dylib.

@stevengj
Copy link
Member

A better workaround, which hopefully will get incorporated into Anaconda, is to run:

run(`install_name_tool -change @rpath/libiomp5.dylib @loader_path/libiomp5.dylib $(Pkg.dir("Conda", "deps/usr/lib/libmkl_intel_thread.dylib"))`)

You only need to do this once (until Conda upgrades MKL).

mingwandroid added a commit to AnacondaRecipes/aggregate that referenced this issue Oct 13, 2017
@anitescu
Copy link

@flamesofmoon : do you per chance have a MAC? Since El Capitan LD_LIBRARY_PATH cannot be set.

@mingwandroid
Copy link

@anitescu, conda does not require DYLD_LIBRARY_PATH or DYLD_FALLBACK_LIBRARY_PATH to be set, does julia? From what I've seen, it does not. You can set those variables anyway provided you disable SIP.

@stevengj
Copy link
Member

No, Julia does not require DYLD_LIBRARY_PATH or similar.

In any case, I would recommend using the install_name_tool -change method rather than setting environment variables as a workaround until the Anaconda patch is merged into the main distro.

@anitescu
Copy link

@mingwandroid : thanks; did not mention that I hoped to not need to disable SIP. I am a bit unclear about how it deals with certain packages, such as CPLEX which itself does require it; but do not understand it enough.

@stevengj : there was this issue
issue to which I believe you also replied, maybe I misunderstood the proposed solution.

I ended up defining the Libdl PATH and process.env.LD_ for atom by hand for the previous issue.

@flamesofmoon
Copy link

@stevengj Well, I still can't work around that. Got the same intel MKL Fatal ERROR.

Anyway, your original idea is good enough. At least I can plot now!

@zashwood
Copy link

zashwood commented Oct 13, 2017

Hi @stevengj Thanks for figuring this out. Running export LD_Library_Path... fixed the Intel MKL FATAL ERROR: Cannot load libmkl_intel_thread.dylib problem for me. However I have tried to run
install_name_tool -change @rpath/libiomp5.dylib @loader_path/libiomp5.dylib $(Pkg.dir("Conda", "deps/usr/lib/libmkl_intel_thread.dylib"))
and I got back:

-bash: command substitution: line 1: syntax error near unexpected token `"Conda",'
-bash: command substitution: line 1: `Pkg.dir("Conda", "deps/usr/lib/libmkl_intel_thread.dylib")'

Do you know what I am doing wrong? Thanks.

@stevengj
Copy link
Member

stevengj commented Oct 13, 2017

@zashwood, $(Pkg.dir(...)) is a Julia thing — it won't work in bash. That's why I said to run it (in Julia) via run(`install_name_tool ....`) above.

@stevengj
Copy link
Member

stevengj commented Oct 30, 2017

Should be fixed with the latest Anaconda release.

@fufjvnvnf
Copy link

I don't seem to have installed anaconda on my computer. The workaround works in the REPL but does not work in jupyter notebook for me.

@rveltz
Copy link

rveltz commented Apr 5, 2019

Hi,

I am seeing the same problem on osx. Is it fixed?

@stevengj
Copy link
Member

stevengj commented Apr 5, 2019

The original problem was fixed more than a year ago. I just tried updating to the latest Conda on my Mac laptop and it continues to work fine. So maybe you are using an ancient Anaconda installation, @rveltz, and need to update.

@rveltz
Copy link

rveltz commented Apr 5, 2019

OK, I am seeing another error. I'll open an issue.

Thank you.

@milankl
Copy link

milankl commented Jun 17, 2020

This issue came up today despite a fresh Julia and following the

julia> ENV["PYTHON"] = ""
julia> Pkg.build("PyCall")

guidline. However, adding this

Setting LD_LIBRARY_PATH explicitly works around the problem, i.e.export LD_LIBRARY_PATH=$HOME/.julia/v0.6/Conda/deps/usr/lib before launching Julia, and then it works for me.

to .zshrc in macos 10.15 solved the issue in the REPL but not inside Atom. Any more clues how this is caused and whether there is a more automatic way around it?

@wizofe
Copy link

wizofe commented Jul 4, 2020

I still have the same problem with:

  • MacOS Catalina v.10.15.5
  • Julia 1.5.0-rc1.0

what I get is:

julia> using PyPlot
[ Info: Precompiling PyPlot [d330b81b-6aea-500a-939a-2ce795aea3ee]
INTEL MKL ERROR: dlopen(local/miniconda3/envs/cvnd3/lib/libmkl_intel_thread.dylib, 9): Library not loaded: @rpath/libiomp5.dylib
  Referenced from: local/miniconda3/envs/cvnd3/lib/libmkl_intel_thread.dylib
  Reason: image not found.
Intel MKL FATAL ERROR: Cannot load libmkl_intel_thread.dylib.

@milankl
Copy link

milankl commented Jul 21, 2020

Setting LD_LIBRARY_PATH explicitly works around the problem, i.e.export LD_LIBRARY_PATH=$HOME/.julia/v0.6/Conda/deps/usr/lib before launching Julia, and then it works for me.

to .zshrc in macos 10.15 solved the issue in the REPL but not inside Atom. Any more clues how this is caused and whether there is a more automatic way around it?

To be precise, I added

export LD_LIBRARY_PATH=/Users/milan/.julia/conda/3/lib:$LD_LIBRARY_PATH

to my .zshrc. Then in Atom you can change in settings the julia-client "Julia Options" from "Basic" to "External Terminal" for example.

@rokapre
Copy link

rokapre commented Mar 28, 2021

I am having this same issue but with just about any Python package. Following the works in the terminal directly but not in the IDEs Atom nor VSCode.

@tlienart
Copy link

tlienart commented Apr 7, 2021

I stumbled upon this issue today on OSX with Julia 1.7, the LD_LIBRARY_PATH trick didn't work but the following did:

using Conda
Conda.rm("mkl")
Conda.add("nomkl")

I'm not sure whether both are needed but it fixed the issue for me.

@xrisk
Copy link

xrisk commented Apr 13, 2021

I’m still facing this issue.

Julia 1.6.0
macOS Big Sur 11.2.3

The LD_LIBRARY_PATH trick works for me. But I’m curious to understand why this happens in the first place. Am I using Julia incorrectly?

@George9000
Copy link

On Julia 1.6.1, macOS 10.15.7

Solution offered by tlienart worked. Thanks!

@willcoxe
Copy link

willcoxe commented May 5, 2021

Solution provided by @tlienart also worked for me with
Julia 1.5.3
OSX Catalina 10.15.7
(Atom 1.56.0)

@TheCedarPrince
Copy link

How peculiar. I can also confirm that @tlienart's solution worked on Julia 1.6 with my mac OSX Catalina 10.15.7. Not sure why.

@KarroyWang001
Copy link

Thanks very much to @tlienart, his solution helps me a lot for my Julia 1.6.1. Still, it confuses me why it happens.

@logankilpatrick
Copy link

@tlienart is going to become famous for this one, thanks for the help! This fixed my issue on my M1 MacBook Pro with Julia 1.6

@johnnychen94
Copy link

To be precise, I added

export LD_LIBRARY_PATH=/Users/milan/.julia/conda/3/lib:$LD_LIBRARY_PATH
to my .zshrc. Then in Atom you can change in settings the julia-client "Julia Options" from "Basic" to "External Terminal" for example.

For custom conda env settings

ENV["CONDA_JL_HOME"] = "/Users/jc/opt/miniconda3/envs/conda_jl"
ENV["PYTHON"] = "" 

Appending LD_LIBRARY_PATH with /Users/jc/opt/miniconda3/envs/conda_jl/lib instead of /Users/jc/.julia/conda/3/lib

@astrobc1
Copy link

astrobc1 commented May 6, 2022

For anyone else stuck with this error, I ended up having to manually copy the file libiomp5.dylib from my anaconda3 folder to the path /Applications/Julia-1.7.app/Contents/Resources/julia/lib/. I tried copying the file libmkl_intel_thread.1.dylib as well into appropriate folders, modifed the LD_LIBRARY_PATH variable, but this was ultimately the only thing that worked.

In my case, this issue started happening after I started using a custom Python installation (the default one I usually use on my machine, not the hidden one inside ~/.julia/).

MacOS Monterey 12.3.1, Julia 1.7.2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests