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

Cannot install FFTW on Apple M2-MAX chip, `libmkl_rt_path` not defined #274

Open xiang-yu opened 1 year ago

xiang-yu commented 1 year ago

Hi everyone,

I've got the following error when installing the "FFTW" package with Julia version 1.9.1 on M2 Max chip with Ventura 13.4

Any tips on resolving this?

using FFTW
 │ Package FFTW not found, but a package named FFTW is available from a registry. 
 │ Install package?
 │   (@v1.9) pkg> add FFTW 
 └ (y/n/o) [y]: y
    Updating registry at `~/.julia/registries/General.toml`
   Resolving package versions...
    Updating `~/.julia/environments/v1.9/Project.toml`
  [7a1cc6ca] + FFTW v1.7.1
    Updating `~/.julia/environments/v1.9/Manifest.toml`
  [621f4979] + AbstractFFTs v1.3.2
  [7a1cc6ca] + FFTW v1.7.1
  [f5851436] + FFTW_jll v3.3.10+0
  [1d5cc7b8] + IntelOpenMP_jll v2023.1.0+0
  [856f044c] + MKL_jll v2023.1.0+0
[ Info: Precompiling FFTW [7a1cc6ca-52ef-59f5-83cd-3a7055c09341]
ERROR: LoadError: UndefVarError: `libmkl_rt_path` not defined
Stacktrace:
 [1] getproperty(x::Module, f::Symbol)
   @ Base ./Base.jl:31
 [2] top-level scope
   @ ~/.julia/packages/FFTW/HfEjB/src/providers.jl:86
 [3] include(mod::Module, _path::String)
   @ Base ./Base.jl:457
 [4] include(x::String)
   @ FFTW ~/.julia/packages/FFTW/HfEjB/src/FFTW.jl:1
 [5] top-level scope
   @ ~/.julia/packages/FFTW/HfEjB/src/FFTW.jl:17
 [6] include
   @ ./Base.jl:457 [inlined]
 [7] include_package_for_output(pkg::Base.PkgId, input::String, depot_path::Vector{String}, dl_load_path::Vector{String}, load_path::Vector{String}, concrete_deps::Vector{Pair{Base.PkgId, UInt128}}, source::Nothing)
   @ Base ./loading.jl:2045
 [8] top-level scope
   @ stdin:3
in expression starting at /Users/.julia/packages/FFTW/HfEjB/src/providers.jl:84
in expression starting at /Users/.julia/packages/FFTW/HfEjB/src/FFTW.jl:1
in expression starting at stdin:3
ERROR: Failed to precompile FFTW [7a1cc6ca-52ef-59f5-83cd-3a7055c09341] to "/Users/.julia/compiled/v1.9/FFTW/jl_HmZkkA".
Stacktrace:
 [1] error(s::String)
   @ Base ./error.jl:35
 [2] compilecache(pkg::Base.PkgId, path::String, internal_stderr::IO, internal_stdout::IO, keep_loaded_modules::Bool)
   @ Base ./loading.jl:2296
 [3] compilecache
   @ ./loading.jl:2163 [inlined]
 [4] _require(pkg::Base.PkgId, env::String)
   @ Base ./loading.jl:1805
 [5] _require_prelocked(uuidkey::Base.PkgId, env::String)
   @ Base ./loading.jl:1660
 [6] macro expansion
   @ ./loading.jl:1648 [inlined]
 [7] macro expansion
   @ ./lock.jl:267 [inlined]
 [8] require(into::Module, mod::Symbol)
   @ Base ./loading.jl:1611
giordano commented 1 year ago

The offending line is https://github.com/JuliaMath/FFTW.jl/blob/008bc5b0b80be127c304d5cf8943d3a657e1e4f7/src/providers.jl#L86 but that's inside the block guarded by https://github.com/JuliaMath/FFTW.jl/blob/008bc5b0b80be127c304d5cf8943d3a657e1e4f7/src/providers.jl#L84 so it appears you are explicitly requesting MKL, which isn't available on ARM CPUs. You should just not do that. See https://juliamath.github.io/FFTW.jl/stable/#Installation

xiang-yu commented 1 year ago

Thanks a lot for your prompt, @giordano! I don't even get a chance to not request for the MKL. Here are my command for installing FFTW. As you see the error occurs before I can execute using FFTW. Any tips on overcoming this? I am totally happy with just using the default version without MKL.

Pkg.add("FFTW")
julia> using FFTW
[ Info: Precompiling FFTW [7a1cc6ca-52ef-59f5-83cd-3a7055c09341]
ERROR: LoadError: UndefVarError: `libmkl_rt_path` not defined
Stacktrace:
 [1] getproperty(x::Module, f::Symbol)
   @ Base ./Base.jl:31
 [2] top-level scope
   @ ~/.julia/packages/FFTW/HfEjB/src/providers.jl:86
 [3] include(mod::Module, _path::String)
   @ Base ./Base.jl:457
 [4] include(x::String)
   @ FFTW ~/.julia/packages/FFTW/HfEjB/src/FFTW.jl:1
 [5] top-level scope
   @ ~/.julia/packages/FFTW/HfEjB/src/FFTW.jl:17
 [6] include
   @ ./Base.jl:457 [inlined]
 [7] include_package_for_output(pkg::Base.PkgId, input::String, depot_path::Vector{String}, dl_load_path::Vector{String}, load_path::Vector{String}, concrete_deps::Vector{Pair{Base.PkgId, UInt128}}, source::Nothing)
   @ Base ./loading.jl:2045
 [8] top-level scope
   @ stdin:3
in expression starting at /Users/.julia/packages/FFTW/HfEjB/src/providers.jl:84
in expression starting at /Users/.julia/packages/FFTW/HfEjB/src/FFTW.jl:1
in expression starting at stdin:3
ERROR: Failed to precompile FFTW [7a1cc6ca-52ef-59f5-83cd-3a7055c09341] to "/Users/.julia/compiled/v1.9/FFTW/jl_8W5MoO".
Stacktrace:
 [1] error(s::String)
   @ Base ./error.jl:35
 [2] compilecache(pkg::Base.PkgId, path::String, internal_stderr::IO, internal_stdout::IO, keep_loaded_modules::Bool)
   @ Base ./loading.jl:2296
 [3] compilecache
   @ ./loading.jl:2163 [inlined]
 [4] _require(pkg::Base.PkgId, env::String)
   @ Base ./loading.jl:1805
 [5] _require_prelocked(uuidkey::Base.PkgId, env::String)
   @ Base ./loading.jl:1660
 [6] macro expansion
   @ ./loading.jl:1648 [inlined]
 [7] macro expansion
   @ ./lock.jl:267 [inlined]
 [8] require(into::Module, mod::Symbol)
   @ Base ./loading.jl:1611
julia> FFTW.set_provider!("fftw")
ERROR: UndefVarError: `FFTW` not defined
Stacktrace:
 [1] top-level scope
   @ REPL[6]:1
giordano commented 1 year ago

Please use triple backticks to quote your code blocks on github, to make the code you post more readable: https://docs.github.com/en/get-started/writing-on-github/working-with-advanced-formatting/creating-and-highlighting-code-blocks

xiang-yu commented 1 year ago

I've now updated my code. How about now? @giordano

giordano commented 1 year ago

Not really, but I fixed that for you again.

Anyway, you're saying that you're trying to install FFTW in a fresh environment without any LocalPreferences.toml file?

xiang-yu commented 1 year ago

Thanks @giordano . Yes, I think so. I used the "Finder" function on Mac and couldn't find it. How to find the LocalPreferences.toml file of the FFTW package?

cd ~/.julia/packages/
rm -rf MKL_jll
rm -rf IntelOpenMP_jll
rm -rf FFTW
rm -rf FFTW_jll
rm -rf AbstractFFTs
julia> Pkg.rm("FFTW")
    Updating `~/.julia/environments/v1.9/Project.toml`
  [7a1cc6ca] - FFTW v1.7.1
    Updating `~/.julia/environments/v1.9/Manifest.toml`
  [621f4979] - AbstractFFTs v1.3.2
  [7a1cc6ca] - FFTW v1.7.1
  [f5851436] - FFTW_jll v3.3.10+0
  [1d5cc7b8] - IntelOpenMP_jll v2023.1.0+0
  [856f044c] - MKL_jll v2023.1.0+0
julia> using FFTW
 │ Package FFTW not found, but a package named FFTW is available from a registry. 
 │ Install package?
 │   (@v1.9) pkg> add FFTW 
 └ (y/n/o) [y]: y
   Resolving package versions...
   Installed MKL_jll ───────── v2023.1.0+0
   Installed IntelOpenMP_jll ─ v2023.1.0+0
   Installed FFTW_jll ──────── v3.3.10+0
   Installed FFTW ──────────── v1.7.1
   Installed AbstractFFTs ──── v1.3.2
    Updating `~/.julia/environments/v1.9/Project.toml`
  [7a1cc6ca] + FFTW v1.7.1
    Updating `~/.julia/environments/v1.9/Manifest.toml`
  [621f4979] + AbstractFFTs v1.3.2
  [7a1cc6ca] + FFTW v1.7.1
  [f5851436] + FFTW_jll v3.3.10+0
  [1d5cc7b8] + IntelOpenMP_jll v2023.1.0+0
  [856f044c] + MKL_jll v2023.1.0+0
Precompiling project...
  ✗ FFTW
  4 dependencies successfully precompiled in 3 seconds. 34 already precompiled.
  1 dependency errored. To see a full report either run `import Pkg; Pkg.precompile()` or load the package
[ Info: Precompiling FFTW [7a1cc6ca-52ef-59f5-83cd-3a7055c09341]
ERROR: LoadError: UndefVarError: `libmkl_rt_path` not defined
Stacktrace:
 [1] getproperty(x::Module, f::Symbol)
   @ Base ./Base.jl:31
 [2] top-level scope
   @ ~/.julia/packages/FFTW/HfEjB/src/providers.jl:86
 [3] include(mod::Module, _path::String)
   @ Base ./Base.jl:457
 [4] include(x::String)
   @ FFTW ~/.julia/packages/FFTW/HfEjB/src/FFTW.jl:1
 [5] top-level scope
   @ ~/.julia/packages/FFTW/HfEjB/src/FFTW.jl:17
 [6] include
   @ ./Base.jl:457 [inlined]
 [7] include_package_for_output(pkg::Base.PkgId, input::String, depot_path::Vector{String}, dl_load_path::Vector{String}, load_path::Vector{String}, concrete_deps::Vector{Pair{Base.PkgId, UInt128}}, source::Nothing)
   @ Base ./loading.jl:2045
 [8] top-level scope
   @ stdin:3
in expression starting at /Users/.julia/packages/FFTW/HfEjB/src/providers.jl:84
in expression starting at /Users/.julia/packages/FFTW/HfEjB/src/FFTW.jl:1
in expression starting at stdin:3
ERROR: Failed to precompile FFTW [7a1cc6ca-52ef-59f5-83cd-3a7055c09341] to "/Users/.julia/compiled/v1.9/FFTW/jl_n1k2mJ".
Stacktrace:
 [1] error(s::String)
   @ Base ./error.jl:35
 [2] compilecache(pkg::Base.PkgId, path::String, internal_stderr::IO, internal_stdout::IO, keep_loaded_modules::Bool)
   @ Base ./loading.jl:2296
 [3] compilecache
   @ ./loading.jl:2163 [inlined]
 [4] _require(pkg::Base.PkgId, env::String)
   @ Base ./loading.jl:1805
 [5] _require_prelocked(uuidkey::Base.PkgId, env::String)
   @ Base ./loading.jl:1660
 [6] macro expansion
   @ ./loading.jl:1648 [inlined]
 [7] macro expansion
   @ ./lock.jl:267 [inlined]
 [8] require(into::Module, mod::Symbol)
   @ Base ./loading.jl:1611
stevengj commented 1 year ago

Is this a completely fresh install of Julia or did you migrate over from an older Mac where you copied your old .julia folder and perhaps inadvertently copied over a package preference for MKL?

Short of deleting ~/.julia and re-installing everything, I think you can set the FFTW preference to be non-MKL without installing FFTW first by something like:

using Preferences, UUIDs
fftw = UUID("7a1cc6ca-52ef-59f5-83cd-3a7055c09341")
set_preferences!(fftw, "provider" => "fftw")
stevengj commented 1 year ago

That being said, maybe we should look at Sys.ARCH before attempting to use MKL.

giordano commented 1 year ago

Or more generally MKL_jll.is_available(), which would would tell whether MKL is available for the current platform or not.

xiang-yu commented 1 year ago

Thank you, @giordano @stevengj , both. I completely uninstalled Julia and reinstalled it ago. The default FFTW works now.