Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix for bytes/str discrepancy after PyNVML update #1118

Merged
merged 2 commits into from
Feb 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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