Skip to content

Commit

Permalink
Merge branch 'master' into consistent-datatype-states-shape-1-1
Browse files Browse the repository at this point in the history
  • Loading branch information
twallema committed Aug 30, 2024
2 parents fc224a3 + f3096ff commit 2fa73a4
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 4 deletions.
17 changes: 17 additions & 0 deletions src/pySODM/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
"""
By setting the following environment variables, pySODM prohibits Numpy, Torch & Tensorflow from automatically multithreading large matrix operations
This does not play nice with the pySODM feature of running the model N times in parallel using multiprocessing
"""

import os

# Numpy & Torch
os.environ['VECLIB_MAXIMUM_THREADS'] = '1'
os.environ['OPENBLAS_NUM_THREADS'] = '1'
os.environ['MKL_NUM_THREADS'] = '1'
os.environ['BLIS_NUM_THREADS'] = '1'
os.environ['NUMEXPR_NUM_THREADS'] = '1'

# Tensorflow
os.environ['TF_NUM_INTEROP_THREADS'] = '1'
os.environ['TF_NUM_INTRAOP_THREADS'] = '1'
4 changes: 0 additions & 4 deletions src/pySODM/models/base.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
# Prevents numpy from using multiple threads to perform computations on large matrices
import os
os.environ["OMP_NUM_THREADS"] = "1"
# Packages
import random
import itertools
import xarray
Expand Down

0 comments on commit 2fa73a4

Please sign in to comment.