Skip to content
Open
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
15 changes: 12 additions & 3 deletions cuda_bindings/tests/nvml/test_compute_mode.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

@pytest.mark.skipif(sys.platform == "win32", reason="Test not supported on Windows")
def test_compute_mode_supported_nonroot(all_devices):
skipped_devices = {} # Using dict (not set) to preserve insertion order.
for device in all_devices:
with unsupported_before(device, None):
original_compute_mode = nvml.device_get_compute_mode(device)
Expand All @@ -26,6 +27,14 @@ def test_compute_mode_supported_nonroot(all_devices):
try:
nvml.device_set_compute_mode(device, cm)
except nvml.NoPermissionError:
skip_reasons.add(f"nvmlDeviceSetComputeMode requires root for device {device}")
continue
assert original_compute_mode == nvml.device_get_compute_mode(device), "Compute mode shouldn't have changed"
skipped_devices[str(device)] = 1 # value is not used.
else:
nvml.device_set_compute_mode(device, original_compute_mode)
assert original_compute_mode == nvml.device_get_compute_mode(device), (
"Compute mode shouldn't have changed"
)

if skipped_devices:
pytest.skip(
f"nvmlDeviceSetComputeMode requires root for {len(skipped_devices)} device(s): {', '.join(skipped_devices)}"
)
Loading