[Core] Do not convert gpu id to int (#9744)

Co-authored-by: Richard Liaw <rliaw@berkeley.edu>
This commit is contained in:
yncxcw
2020-08-11 13:09:46 -06:00
committed by GitHub
parent d6226b80bb
commit 32cd94b750
9 changed files with 54 additions and 20 deletions
+6 -5
View File
@@ -271,9 +271,9 @@ def get_cuda_visible_devices():
"""Get the device IDs in the CUDA_VISIBLE_DEVICES environment variable.
Returns:
if CUDA_VISIBLE_DEVICES is set, this returns a list of integers with
the IDs of the GPUs. If it is not set or is set to NoDevFiles,
this returns None.
devices (List[str]): If CUDA_VISIBLE_DEVICES is set, returns a
list of strings representing the IDs of the visible GPUs.
If it is not set or is set to NoDevFiles, returns empty list.
"""
gpu_ids_str = os.environ.get("CUDA_VISIBLE_DEVICES", None)
@@ -286,7 +286,8 @@ def get_cuda_visible_devices():
if gpu_ids_str == "NoDevFiles":
return []
return [int(i) for i in gpu_ids_str.split(",")]
# GPU identifiers are given as strings representing integers or UUIDs.
return list(gpu_ids_str.split(","))
last_set_gpu_ids = None
@@ -296,7 +297,7 @@ def set_cuda_visible_devices(gpu_ids):
"""Set the CUDA_VISIBLE_DEVICES environment variable.
Args:
gpu_ids: This is a list of integers representing GPU IDs.
gpu_ids (List[str]): List of strings representing GPU IDs.
"""
global last_set_gpu_ids