File tree 2 files changed +9
-7
lines changed
2 files changed +9
-7
lines changed Original file line number Diff line number Diff line change @@ -32,7 +32,8 @@ class NVMLState(IntEnum):
32
32
33
33
34
34
class CudaDeviceInfo (NamedTuple ):
35
- uuid : bytes | None = None
35
+ # Older versions of pynvml returned bytes, newer versions return str.
36
+ uuid : str | bytes | None = None
36
37
device_index : int | None = None
37
38
mig_index : int | None = None
38
39
@@ -278,13 +279,13 @@ def get_device_index_and_uuid(device):
278
279
Examples
279
280
--------
280
281
>>> get_device_index_and_uuid(0) # doctest: +SKIP
281
- {'device-index': 0, 'uuid': b 'GPU-e1006a74-5836-264f-5c26-53d19d212dfe'}
282
+ {'device-index': 0, 'uuid': 'GPU-e1006a74-5836-264f-5c26-53d19d212dfe'}
282
283
283
284
>>> get_device_index_and_uuid('GPU-e1006a74-5836-264f-5c26-53d19d212dfe') # doctest: +SKIP
284
- {'device-index': 0, 'uuid': b 'GPU-e1006a74-5836-264f-5c26-53d19d212dfe'}
285
+ {'device-index': 0, 'uuid': 'GPU-e1006a74-5836-264f-5c26-53d19d212dfe'}
285
286
286
287
>>> get_device_index_and_uuid('MIG-7feb6df5-eccf-5faa-ab00-9a441867e237') # doctest: +SKIP
287
- {'device-index': 0, 'uuid': b 'MIG-7feb6df5-eccf-5faa-ab00-9a441867e237'}
288
+ {'device-index': 0, 'uuid': 'MIG-7feb6df5-eccf-5faa-ab00-9a441867e237'}
288
289
"""
289
290
init_once ()
290
291
try :
Original file line number Diff line number Diff line change 11
11
pynvml = pytest .importorskip ("pynvml" )
12
12
13
13
import dask
14
+ from dask .utils import ensure_unicode
14
15
15
16
from distributed .diagnostics import nvml
16
17
from distributed .utils_test import gen_cluster
@@ -66,7 +67,7 @@ def run_has_cuda_context(queue):
66
67
assert (
67
68
ctx .has_context
68
69
and ctx .device_info .device_index == 0
69
- and isinstance (ctx .device_info .uuid , bytes )
70
+ and isinstance (ctx .device_info .uuid , str )
70
71
)
71
72
72
73
queue .put (None )
@@ -127,7 +128,7 @@ def test_visible_devices_uuid():
127
128
assert info .uuid
128
129
129
130
with mock .patch .dict (
130
- os .environ , {"CUDA_VISIBLE_DEVICES" : info .uuid . decode ( "utf-8" )}
131
+ os .environ , {"CUDA_VISIBLE_DEVICES" : ensure_unicode ( info .uuid )}
131
132
):
132
133
h = nvml ._pynvml_handles ()
133
134
h_expected = pynvml .nvmlDeviceGetHandleByIndex (0 )
@@ -147,7 +148,7 @@ def test_visible_devices_uuid_2(index):
147
148
assert info .uuid
148
149
149
150
with mock .patch .dict (
150
- os .environ , {"CUDA_VISIBLE_DEVICES" : info .uuid . decode ( "utf-8" )}
151
+ os .environ , {"CUDA_VISIBLE_DEVICES" : ensure_unicode ( info .uuid )}
151
152
):
152
153
h = nvml ._pynvml_handles ()
153
154
h_expected = pynvml .nvmlDeviceGetHandleByIndex (index )
You can’t perform that action at this time.
0 commit comments