Skip to content

Commit

Permalink
Fix for bytes/str discrepancy after PyNVML update (#1118)
Browse files Browse the repository at this point in the history
A PyNVML update has changed how some objects were previously returned bytes but now return str, which is now handled appropriately with this change.

Authors:
  - Peter Andreas Entschev (https://github.com/pentschev)

Approvers:
  - Lawrence Mitchell (https://github.com/wence-)

URL: #1118
  • Loading branch information
pentschev authored Feb 15, 2023
1 parent a0fda76 commit 8134e6b
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
7 changes: 5 additions & 2 deletions dask_cuda/tests/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -189,13 +189,16 @@ def test_parse_visible_devices():
uuids = []
for index in range(get_gpu_count()):
handle = pynvml.nvmlDeviceGetHandleByIndex(index)
uuid = pynvml.nvmlDeviceGetUUID(handle).decode("utf-8")
try:
uuid = pynvml.nvmlDeviceGetUUID(handle).decode("utf-8")
except AttributeError:
uuid = pynvml.nvmlDeviceGetUUID(handle)

assert parse_cuda_visible_device(index) == index
assert parse_cuda_visible_device(uuid) == uuid

indices.append(str(index))
uuids.append(pynvml.nvmlDeviceGetUUID(handle).decode("utf-8"))
uuids.append(uuid)

index_devices = ",".join(indices)
with patch.dict(os.environ, {"CUDA_VISIBLE_DEVICES": index_devices}):
Expand Down
5 changes: 4 additions & 1 deletion dask_cuda/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -676,7 +676,10 @@ def get_gpu_uuid_from_index(device_index=0):

pynvml.nvmlInit()
handle = pynvml.nvmlDeviceGetHandleByIndex(device_index)
return pynvml.nvmlDeviceGetUUID(handle).decode("utf-8")
try:
return pynvml.nvmlDeviceGetUUID(handle).decode("utf-8")
except AttributeError:
return pynvml.nvmlDeviceGetUUID(handle)


def get_worker_config(dask_worker):
Expand Down

0 comments on commit 8134e6b

Please sign in to comment.