JuliaMath / FFTW.jl

Julia bindings to the FFTW library for fast Fourier transforms
https://juliamath.github.io/FFTW.jl/stable
MIT License
273 stars 55 forks source link

`Intel MKL FATAL ERROR: Cannot load libmkl_intel_thread.2.dylib.` on x86_64 macOS #281

Closed AshtonSBradley closed 10 months ago

AshtonSBradley commented 10 months ago

280 was not fixed by installing the 2023 mkl:

pkg> add MKL_jll@2023
   Resolving package versions...
    Updating `~/.julia/environments/v1.10/Project.toml`
⌅ [856f044c] + MKL_jll v2023.2.0+0
  No Changes to `~/.julia/environments/v1.10/Manifest.toml`

julia> using FFTW

julia> FFTW.get_provider()
"fftw"

julia> FFTW.set_provider!("mkl")
┌ Info: FFTW provider changed; restart Julia for this change to take effect
└   provider = "mkl"

julia> exit()

julia> using FFTW

julia> FFTW.get_provider()
"mkl"

julia> fft(randn(10))

Intel MKL FATAL ERROR: Cannot load libmkl_intel_thread.2.dylib.
AshtonSBradley commented 10 months ago

so I think my question is still open: how do I choose the MKL used by FFTW?

giordano commented 10 months ago

What's the output of

]st -m MKL_jll

in that environment?

AshtonSBradley commented 10 months ago
(@v1.10) pkg> st -m MKL_jll
Status `~/.julia/environments/v1.10/Manifest.toml`
⌅ [856f044c] MKL_jll v2023.2.0+0
Info Packages marked with ⌅ have new versions available but compatibility constraints restrict them from upgrading. To see why use `status --outdated -m`
giordano commented 10 months ago

Well, MKL_jll 2023.2.0+0 does have the x86_64 Darwin build: https://github.com/JuliaBinaryWrappers/MKL_jll.jl/blob/MKL-v2023.2.0%2B0/src/wrappers/x86_64-apple-darwin.jl, https://github.com/JuliaBinaryWrappers/MKL_jll.jl/blob/596307356acbf1806b77b6c0f7233de501c4bb02/Artifacts.toml#L39-L47

AshtonSBradley commented 10 months ago

how do I query which MKL is being used by fftw?

giordano commented 10 months ago
using MKL_jll
pkgversion(MKL_jll)
giordano commented 10 months ago

Also

using MKL_jll
MKL_jll.is_available()
AshtonSBradley commented 10 months ago

ok, I don't know internals, but I got the impression that fftw installs is own MKL and presumably this is distinct from user installed, because deps run their own versioning. When I install FFTW on its own I don't see an MKL_jll appear in the project. If I install my own MKL_jll I would assume that this is distinct from the one FFTW uses for its own deps, no?

giordano commented 10 months ago

but I got the impression that fftw installs is own MKL

No: https://github.com/JuliaMath/FFTW.jl/blob/ef8fc5b781da762a5332d62341fecd10fbccb658/Project.toml#L5-L9

I install FFTW on its own I don't see an MKL_jll appear in the project.

That seems unlikely since MKL_jll is a direct dependency of this package. How are you checking the project? For example, ]st only shows the the packages you installed directly, but if you want to see also the other packages pulled by your packages you have to use ]st -m, as suggested above.

If I install my own MKL_jll I would assume that this is distinct from the one FFTW uses for its own deps, no?

No. Why would it be the case? In each environment there can be one and only one version of each package.

giordano commented 10 months ago
]add IntelOpenMP_jll@2023

Should fix your problem.

AshtonSBradley commented 10 months ago
]add IntelOpenMP_jll@2023

Should fix your problem.

Fixed. Thanks for your help and explanation!