[minor][core] fix gpu ids for SLURM (#7014)

* fix gpu ids

* fix
This commit is contained in:
Richard Liaw 2020-02-02 16:09:22 -08:00 committed by GitHub
parent 9d04f6617a
commit 52c33b53f7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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(",")]