-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* fix numpy import * optimize circle ci performance Co-authored-by: /bin/eash <[email protected]>
- Loading branch information
Showing
10 changed files
with
102 additions
and
81 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,20 +2,22 @@ | |
# Author: Jiajun Ren <[email protected]> | ||
import os | ||
import sys | ||
import warnings | ||
|
||
if "numpy" in sys.modules: | ||
raise ImportError("renormalizer should be imported before numpy is imported") | ||
|
||
# set environment variables to limit NumPy cpu usage | ||
# Note that this should be done before NumPy is imported | ||
for env in ["MKL_NUM_THREADS", "NUMEXPR_NUM_THREADS", "OMP_NUM_THREADS"]: | ||
os.environ[env] = "1" | ||
del env | ||
reno_num_threads = os.environ.get("RENO_NUM_THREADS") | ||
if reno_num_threads is not None: | ||
# set environment variables to limit NumPy cpu usage | ||
# Note that this should be done before NumPy is imported | ||
|
||
# NEP-18 not working. For compatibility of newer NumPy version. See gh-cupy/cupy#2130 | ||
os.environ["NUMPY_EXPERIMENTAL_ARRAY_FUNCTION"] = "0" | ||
if "numpy" in sys.modules: | ||
warnings.warn("renormalizer should be imported before numpy for `RENO_NUM_THREADS` to take effect") | ||
else: | ||
for env in ["MKL_NUM_THREADS", "NUMEXPR_NUM_THREADS", "OMP_NUM_THREADS"]: | ||
os.environ[env] = reno_num_threads | ||
del env | ||
|
||
del os, sys | ||
del os, sys, warnings | ||
|
||
from renormalizer.utils.log import init_log | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.