From MKL back to OpenBLAS

After building MKL on Julia.

julia>]add https://github.com/JuliaComputing/MKL.jl

julia>] build MKL

Is there a way to set OpenBLAS back?

1 Like

Probably not the best way but reinstalling Julia works. At least on Mac I can just run the install and replace the current install and REPL history etc will still be left.

At the end that is just what I did. I wanted to know if there was an easy and fast way to switch between both in order to perform some benchmarks.

1 Like

This should work: https://github.com/JuliaComputing/MKL.jl/blob/61720ba15055424dde7dabfef8e3880eebbd4566/src/install.jl#L83

2 Likes

It took a few minutes (to be exact since you replied) for the re-build, but I had not expected for it to be faster. Thanks, that’s exactly what I was looking for.

I tried to run the install script in Julia and executed

julia> enable_openblas_startup()
[ Info: Removing code to load MKL in C:\Users\Win10\AppData\Local\Programs\Julia-1.6.3\bin\..\share\julia\base\sysimg.jl
[ Info: getting precompile script from: https://raw.githubusercontent.com/JuliaLang/julia/release-1.6/contrib/generate_precompile.jl
┌ Warning: Base.download is deprecated; use Downloads.download instead
│   caller = get_precompile_statments_file() at switchblas.jl:75
└ @ Main C:\Users\Win10\source\repos\julia\idioms\test\switchblas.jl:75
ERROR: UndefKeywordError: keyword argument sysimage_path not assigned

Is this borken or am I doing it wrong? Nevermind I’m doing it wrong. Used a newer, unsupported version of the package compiler, it seems.

For Julia 1.7 you don’t have to do anything else than just restarting Julia. We even want to add a way to dynamically switch back to OpenBLAS (or back and forth) at some point. However, no one has implemented that yet despite the fact that it should be fairly simple. See Switch between MKL and OpenBLAS at runtime · Issue #90 · JuliaLinearAlgebra/MKL.jl · GitHub

1 Like

Just use 1.7 for MKL. It’s just not worth dealing with 1.6 when it comes to this.

5 Likes

The following seems to work, for switching at run-time in Julia 1.7.
No need to restart.

julia> using LinearAlgebra

julia> BLAS.get_config()
LinearAlgebra.BLAS.LBTConfig
Libraries: 
└ [ILP64] libopenblas64_.so

julia> using MKL

julia> BLAS.get_config()
LinearAlgebra.BLAS.LBTConfig
Libraries: 
└ [ILP64] libmkl_rt.so

julia> LinearAlgebra.__init__()

julia> BLAS.get_config()
LinearAlgebra.BLAS.LBTConfig
Libraries: 
└ [ILP64] libopenblas64_.so

julia> MKL.__init__()
4770

julia> BLAS.get_config()
LinearAlgebra.BLAS.LBTConfig
Libraries: 
└ [ILP64] libmkl_rt.so

Credits to @giordano (though he also warned this might not be proper way to switch).

2 Likes