From 52c33b53f78852359101370abdf10db5b5240adf Mon Sep 17 00:00:00 2001 From: Richard Liaw Date: Sun, 2 Feb 2020 16:09:22 -0800 Subject: [PATCH] [minor][core] fix gpu ids for SLURM (#7014) * fix gpu ids * fix --- python/ray/utils.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/python/ray/utils.py b/python/ray/utils.py index 152c4d1e4..dc07df371 100644 --- a/python/ray/utils.py +++ b/python/ray/utils.py @@ -15,6 +15,8 @@ import uuid import ray.gcs_utils import ray.ray_constants as ray_constants +logger = logging.getLogger(__name__) + def _random_string(): id_hash = hashlib.sha1() @@ -261,7 +263,8 @@ def get_cuda_visible_devices(): Returns: if CUDA_VISIBLE_DEVICES is set, this returns a list of integers with - the IDs of the GPUs. If it is not set, this returns None. + the IDs of the GPUs. If it is not set or is set to NoDevFiles, + this returns None. """ gpu_ids_str = os.environ.get("CUDA_VISIBLE_DEVICES", None) @@ -271,6 +274,9 @@ def get_cuda_visible_devices(): if gpu_ids_str == "": return [] + if gpu_ids_str == "NoDevFiles": + return [] + return [int(i) for i in gpu_ids_str.split(",")]