DifferentialEquations.jl precompilation fails for not finding libopenblas

I am using Julia 1.6.3 on Ubuntu 20.04 built from source with MKL turned on, so BLAS.vendor() says MKL. Now, I was trying to install the DifferentialEquations package simply by ] add DifferentialEquations, which after precompile, throws the below error.

A quick glance at the error shows that it couldn’t find libopenblas64_.so library. I can’t understand whether its looking in the system (PS: I have libopenblas.so available through LD_LIBRARY_PATH) or some local location ? Or is it just not possible to use these libraries when Julia is build with MKL ?

Similar issue have been posted here before or on github, suggest to clean ~/.julia/ folder, which didn’t help.

(@v1.6) pkg> precompile
Precompiling project...
  ✗ SuiteSparse_jll
  ✗ Sundials_jll
  ✗ Sundials
  ✗ DifferentialEquations
  0 dependencies successfully precompiled in 22 seconds (173 already precompiled)

ERROR: The following 1 direct dependency failed to precompile:

DifferentialEquations [0c46a032-eb83-5123-abaf-570d42b7fbaa]

Failed to precompile DifferentialEquations [0c46a032-eb83-5123-abaf-570d42b7fbaa] to /user/HS229/ad01424/.julia/compiled/v1.6/DifferentialEquations/jl_FdQ9ya.
ERROR: LoadError: LoadError: InitError: could not load library "libopenblas64_.so"
libopenblas64_.so: cannot open shared object file: No such file or directory
Stacktrace:
  [1] dlopen(s::String, flags::UInt32; throw_error::Bool)
    @ Base.Libc.Libdl ./libdl.jl:114
  [2] dlopen (repeats 2 times)
    @ ./libdl.jl:114 [inlined]
  [3] __init__()
    @ OpenBLAS_jll /vol/research/sketchapp/julia/v1.6.3/share/julia/stdlib/v1.6/OpenBLAS_jll/src/OpenBLAS_jll.jl:35
  [4] _include_from_serialized(path::String, depmods::Vector{Any})
    @ Base ./loading.jl:696
  [5] _require_search_from_serialized(pkg::Base.PkgId, sourcepath::String)
    @ Base ./loading.jl:782
  [6] _require(pkg::Base.PkgId)
    @ Base ./loading.jl:1020
  [7] require(uuidkey::Base.PkgId)
    @ Base ./loading.jl:936
  [8] require(into::Module, mod::Symbol)
    @ Base ./loading.jl:923
  [9] include(mod::Module, _path::String)
    @ Base ./Base.jl:386
 [10] include(x::String)
    @ Sundials_jll ~/.julia/packages/Sundials_jll/heTyl/src/Sundials_jll.jl:1
 [11] top-level scope
    @ ~/.julia/packages/Sundials_jll/heTyl/src/Sundials_jll.jl:54
 [12] include
    @ ./Base.jl:386 [inlined]
 [13] 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, UInt64}}, source::String)
    @ Base ./loading.jl:1235
 [14] top-level scope
    @ none:1
 [15] eval
    @ ./boot.jl:360 [inlined]
 [16] eval(x::Expr)
    @ Base.MainInclude ./client.jl:446
 [17] top-level scope
    @ none:1
during initialization of module OpenBLAS_jll
in expression starting at /user/HS229/ad01424/.julia/packages/Sundials_jll/heTyl/src/wrappers/x86_64-linux-gnu-libgfortran4.jl:5
in expression starting at /user/HS229/ad01424/.julia/packages/Sundials_jll/heTyl/src/Sundials_jll.jl:1
ERROR: LoadError: Failed to precompile Sundials_jll [fb77eaff-e24c-56d4-86b1-d163f2edb164] to /user/HS229/ad01424/.julia/compiled/v1.6/Sundials_jll/jl_7yHnUe.
Stacktrace:
  [1] error(s::String)
    @ Base ./error.jl:33
  [2] compilecache(pkg::Base.PkgId, path::String, internal_stderr::IOContext{Base.PipeEndpoint}, internal_stdout::IOContext{IOStream}, ignore_loaded_modules::Bool)
    @ Base ./loading.jl:1385
  [3] compilecache(pkg::Base.PkgId, path::String)
    @ Base ./loading.jl:1329
  [4] _require(pkg::Base.PkgId)
    @ Base ./loading.jl:1043
  [5] require(uuidkey::Base.PkgId)
    @ Base ./loading.jl:936
  [6] require(into::Module, mod::Symbol)
    @ Base ./loading.jl:923
  [7] include
    @ ./Base.jl:386 [inlined]
  [8] 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, UInt64}}, source::String)
    @ Base ./loading.jl:1235
  [9] top-level scope
    @ none:1
 [10] eval
    @ ./boot.jl:360 [inlined]
 [11] eval(x::Expr)
    @ Base.MainInclude ./client.jl:446
 [12] top-level scope
    @ none:1
in expression starting at /user/HS229/ad01424/.julia/packages/Sundials/sg9S0/src/Sundials.jl:3
ERROR: LoadError: Failed to precompile Sundials [c3572dad-4567-51f8-b174-8c6c989267f4] to /user/HS229/ad01424/.julia/compiled/v1.6/Sundials/jl_Cbtg52.
Stacktrace:
  [1] error(s::String)
    @ Base ./error.jl:33
  [2] compilecache(pkg::Base.PkgId, path::String, internal_stderr::IOContext{Base.PipeEndpoint}, internal_stdout::IOContext{IOStream}, ignore_loaded_modules::Bool)
    @ Base ./loading.jl:1385
  [3] compilecache(pkg::Base.PkgId, path::String)
    @ Base ./loading.jl:1329
  [4] _require(pkg::Base.PkgId)
    @ Base ./loading.jl:1043
  [5] require(uuidkey::Base.PkgId)
    @ Base ./loading.jl:936
  [6] require(into::Module, mod::Symbol)
    @ Base ./loading.jl:923
  [7] include
    @ ./Base.jl:386 [inlined]
  [8] 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, UInt64}}, source::Nothing)
    @ Base ./loading.jl:1235
  [9] top-level scope
    @ none:1
 [10] eval
    @ ./boot.jl:360 [inlined]
 [11] eval(x::Expr)
    @ Base.MainInclude ./client.jl:446
 [12] top-level scope
    @ none:1
in expression starting at /user/HS229/ad01424/.julia/packages/DifferentialEquations/7WPQg/src/DifferentialEquations.jl:1

Maybe this is a @staticfloat or @giordano question?

To be honest, my recommendation is to use MKL.jl with Julia v1.7+ (v1.7.0-rc2 was just announced), it makes so much easier switching BLAS library that spending time on debugging problems with older versions isn’t much worth the effort :slightly_smiling_face:

2 Likes

@giordano Ok. I took your suggestion and got v1.7.0-rc2 with MKL.jl and it works fine now.

2 Likes

Hi, @dasayan05! I had the same problem right now. I found that libopenblas64_.so was in /usr/lib/julia as it came with julia. I fixed it by appending /usr/lib/julia to my LD_LIBRARY_PATH, which you do by appending to bashrc

export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/lib/julia

or in fish

set -gx LD_LIBRARY_PATH $LD_LIBRARY_PATH /usr/lib/julia

I located where the so actually was using the locate utility. Everything that failed now precompiles normally.

Julia’s directory should be the first, not the last one

I am not convinced that it should be the first. It would be the case if my only use for shared libraries was julia, but it isn’t.
Please, let me know if I am missing something…

If you want Julia to work, that directory must be the first one. If other libraries in other directories are picked up first you don’t solve anything. My recommendation is actually that start Julia with

LD_LIBRARY_PATH="" julia

A shell wrapper would do it.

I do not recommend setting LD_LIBRARY_PATH with julia directories for other programs. In the same way I don’t recommend setting LD_LIBRARY_PATH with other directories for Julia. LD_LIBRARY_PATH should be as minimal and as local as possible, a global catch-all setting is problematic.

1 Like