Skip to content

Commit 70365a2

Browse files
authored
Make test robust to running as root or not (#1515)
1 parent 8d8f29b commit 70365a2

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

cuda_bindings/tests/nvml/test_compute_mode.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
1+
# SPDX-FileCopyrightText: Copyright (c) 2025-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
22
# SPDX-License-Identifier: LicenseRef-NVIDIA-SOFTWARE-LICENSE
33

44

@@ -23,6 +23,9 @@ def test_compute_mode_supported_nonroot(all_devices):
2323
original_compute_mode = nvml.device_get_compute_mode(device)
2424

2525
for cm in COMPUTE_MODES:
26-
with pytest.raises(nvml.NoPermissionError):
26+
try:
2727
nvml.device_set_compute_mode(device, cm)
28+
except nvml.NoPermissionError:
29+
skip_reasons.add(f"nvmlDeviceSetComputeMode requires root for device {device}")
30+
continue
2831
assert original_compute_mode == nvml.device_get_compute_mode(device), "Compute mode shouldn't have changed"

0 commit comments

Comments
 (0)