Force OMP_NUM_THREADS=1 if unset (#6998)

* force omp

* update

* set

* workers

* link
This commit is contained in:
Eric Liang
2020-02-01 11:46:11 -08:00
committed by GitHub
parent 3c60caa448
commit 8b4b49662b
3 changed files with 30 additions and 7 deletions
+10
View File
@@ -1,7 +1,11 @@
import os
import logging
import multiprocessing
from os.path import dirname
import sys
logger = logging.getLogger(__name__)
# MUST add pickle5 to the import path because it will be imported by some
# raylet modules.
@@ -10,6 +14,12 @@ if "pickle5" in sys.modules:
"requires a specific version of pickle5 (which is "
"packaged along with Ray).")
if "OMP_NUM_THREADS" not in os.environ and multiprocessing.cpu_count() > 8:
logger.warning("[ray] Forcing OMP_NUM_THREADS=1 to avoid performance "
"degradation with many workers (issue #6998). You can "
"override this by explicitly setting OMP_NUM_THREADS.")
os.environ["OMP_NUM_THREADS"] = "1"
# Add the directory containing pickle5 to the Python path so that we find the
# pickle5 version packaged with ray and not a pre-existing pickle5.
pickle5_path = os.path.join(