Skip to content

Commit 8f114fc

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 8f114fc

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

stdlib/Distributed/src/managers.jl

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -463,6 +463,13 @@ function launch(manager::LocalManager, params::Dict, launched::Array, c::Conditi
463463
exeflags = params[:exeflags]
464464
bind_to = manager.restrict ? `127.0.0.1` : `$(LPROC.bind_addr)`
465465

466+
# If we haven't explicitly asked for threaded BLAS, prevent OpenBLAS from starting
467+
# up with multiple threads, thereby sucking up a bunch of wasted memory on Windows.
468+
if !params[:enable_threaded_blas] &&
469+
get(env, "OPENBLAS_NUM_THREADS", nothing) === nothing
470+
env["OPENBLAS_NUM_THREADS"] = "1"
471+
end
472+
466473
for i in 1:manager.np
467474
cmd = `$(julia_cmd(exename)) $exeflags --bind-to $bind_to --worker`
468475
io = open(detach(setenv(cmd, dir=dir)), "r+")

0 commit comments

Comments
 (0)