From a8b5bcc2822e11c1ea420f550737630e992f40d7 Mon Sep 17 00:00:00 2001 From: Michael Droettboom Date: Thu, 22 Jan 2026 07:57:53 -0500 Subject: [PATCH] Make test robust to running as root or not --- cuda_bindings/tests/nvml/test_compute_mode.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/cuda_bindings/tests/nvml/test_compute_mode.py b/cuda_bindings/tests/nvml/test_compute_mode.py index 3a8079adbf..8e5d6bf6e7 100644 --- a/cuda_bindings/tests/nvml/test_compute_mode.py +++ b/cuda_bindings/tests/nvml/test_compute_mode.py @@ -1,4 +1,4 @@ -# SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved. +# SPDX-FileCopyrightText: Copyright (c) 2025-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. # SPDX-License-Identifier: LicenseRef-NVIDIA-SOFTWARE-LICENSE @@ -25,8 +25,11 @@ def test_compute_mode_supported_nonroot(all_devices): continue for cm in COMPUTE_MODES: - with pytest.raises(nvml.NoPermissionError): + 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" if skip_reasons: