Skip to content

Commit c1a0db0

Browse files
committed
Fix cuda_bindings part of the tests
1 parent 907bf3b commit c1a0db0

1 file changed

Lines changed: 14 additions & 7 deletions

File tree

cuda_bindings/tests/nvml/conftest.py

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -107,15 +107,22 @@ def nmigs(handles):
107107
@pytest.fixture
108108
def mig_handles(nmigs):
109109
handles = []
110-
for dev in all_devices():
111-
for idx in range(nmigs):
110+
with NVMLInitializer():
111+
dev_count = nvml.device_get_count_v2()
112+
113+
for dev_idx in range(dev_count):
112114
try:
113-
handle = nvml.device_get_mig_device_handle_by_index(dev, idx)
114-
except nvml.NotFoundError:
115-
# Not all MIG devices may be available
115+
dev = nvml.device_get_handle_by_index_v2(dev_idx)
116+
except nvml.NoPermissionError:
116117
continue
117-
else:
118-
handles.append(handle)
118+
for mig_idx in range(nmigs):
119+
try:
120+
mig = nvml.device_get_mig_device_handle_by_index(dev, mig_idx)
121+
except nvml.NotFoundError:
122+
# Not all MIG devices may be available
123+
continue
124+
else:
125+
handles.append(mig)
119126
return handles
120127

121128

0 commit comments

Comments
 (0)