Skip to content

Commit

Permalink
Set OPENBLAS_NUM_THREADS=1 on local Distributed workers (#47803)
Browse files Browse the repository at this point in the history
This should prevent LinearAlgebra from trying to increase our OpenBLAS
thread count in its `__init__()` method when we're not trying to enable
threaded BLAS.

(cherry picked from commit a8b3994)
  • Loading branch information
staticfloat authored and KristofferC committed Dec 14, 2022
1 parent 5ab5e35 commit dd0e839
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions stdlib/Distributed/src/managers.jl
Original file line number Diff line number Diff line change
Expand Up @@ -462,6 +462,14 @@ function launch(manager::LocalManager, params::Dict, launched::Array, c::Conditi
exename = params[:exename]
exeflags = params[:exeflags]
bind_to = manager.restrict ? `127.0.0.1` : `$(LPROC.bind_addr)`
env = Dict{String,String}(params[:env])

# If we haven't explicitly asked for threaded BLAS, prevent OpenBLAS from starting
# up with multiple threads, thereby sucking up a bunch of wasted memory on Windows.
if !params[:enable_threaded_blas] &&
get(env, "OPENBLAS_NUM_THREADS", nothing) === nothing
env["OPENBLAS_NUM_THREADS"] = "1"
end

for i in 1:manager.np
cmd = `$(julia_cmd(exename)) $exeflags --bind-to $bind_to --worker`
Expand Down

0 comments on commit dd0e839

Please sign in to comment.