Skip to content

Commit 2180a31

Browse files
committed
multithread fix
1 parent 6caf288 commit 2180a31

2 files changed

Lines changed: 3 additions & 4 deletions

File tree

matexp/__init__.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
from .optimizer import Optimize1D, Optimize2D
1919
from pathlib import Path
2020
import multiprocessing
21+
import threadpoolctl
2122
import numpy as np
2223
import dill
2324
import time
@@ -50,9 +51,7 @@ def _initialize_worker_process(derivative_pickle):
5051
global _derivative
5152
_derivative = dill.loads(derivative_pickle)
5253
# Disable automatic multithreading
53-
os.environ['OPENBLAS_NUM_THREADS'] = '1'
54-
os.environ['MKL_NUM_THREADS'] = '1'
55-
os.environ['OMP_NUM_THREADS'] = '1'
54+
threadpoolctl.ThreadpoolController().limit(limits=1)
5655

5756
def main(nmodl_filename, inputs, time_step, temperature,
5857
error, target,

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,5 +27,5 @@
2727
"Operating System :: OS Independent",
2828
]
2929
requires-python = ">=3.8"
30-
dependencies = ["neuron", "numpy", "scipy", "dill"]
30+
dependencies = ["neuron", "numpy", "scipy", "dill", "threadpoolctl"]
3131
scripts = {matexp = "matexp:__main__._placeholder", matexp-manual = "matexp:manual._placeholder"}

0 commit comments

Comments
 (0)