Skip to content

Commit dd0e839

Browse files
staticfloatKristofferC
authored andcommitted
Set OPENBLAS_NUM_THREADS=1 on local Distributed workers (#47803)
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)
1 parent 5ab5e35 commit dd0e839

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

stdlib/Distributed/src/managers.jl

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -462,6 +462,14 @@ function launch(manager::LocalManager, params::Dict, launched::Array, c::Conditi
462462
exename = params[:exename]
463463
exeflags = params[:exeflags]
464464
bind_to = manager.restrict ? `127.0.0.1` : `$(LPROC.bind_addr)`
465+
env = Dict{String,String}(params[:env])
466+
467+
# If we haven't explicitly asked for threaded BLAS, prevent OpenBLAS from starting
468+
# up with multiple threads, thereby sucking up a bunch of wasted memory on Windows.
469+
if !params[:enable_threaded_blas] &&
470+
get(env, "OPENBLAS_NUM_THREADS", nothing) === nothing
471+
env["OPENBLAS_NUM_THREADS"] = "1"
472+
end
465473

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

0 commit comments

Comments
 (0)