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 8f114fc
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions stdlib/Distributed/src/managers.jl
Original file line number Diff line number Diff line change
Expand Up @@ -463,6 +463,13 @@ function launch(manager::LocalManager, params::Dict, launched::Array, c::Conditi
exeflags = params[:exeflags]
bind_to = manager.restrict ? `127.0.0.1` : `$(LPROC.bind_addr)`

# 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`
io = open(detach(setenv(cmd, dir=dir)), "r+")
Expand Down

0 comments on commit 8f114fc

Please sign in to comment.