File tree Expand file tree Collapse file tree 1 file changed +11
-1
lines changed
Expand file tree Collapse file tree 1 file changed +11
-1
lines changed Original file line number Diff line number Diff line change 11# SPDX-FileCopyrightText: Copyright (c) 2025-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
22# SPDX-License-Identifier: LicenseRef-NVIDIA-SOFTWARE-LICENSE
33
4+ import os
5+
46import cuda .bindings .driver as cuda
57from cuda .bindings import nvml
68
@@ -54,4 +56,12 @@ def test_cuda_device_order():
5456 cuda_devices = get_cuda_device_names ()
5557 nvml_devices = get_nvml_device_names ()
5658
57- assert cuda_devices == nvml_devices , "CUDA and NVML device lists do not match"
59+ if "CUDA_VISIBLE_DEVICES" not in os .environ :
60+ # If that environment variable isn't set, the device lists should match exactly
61+ assert cuda_devices == nvml_devices , "CUDA and NVML device lists do not match"
62+ else :
63+ # If the environment variable is set, there may possibly be fewer CUDA devices,
64+ # and each of them should still be found in NVML devices.
65+ assert len (cuda_devices ) <= len (nvml_devices )
66+ for cuda_device in cuda_devices :
67+ assert cuda_device in nvml_devices , f"CUDA device { cuda_device } not found in NVML device list"
You can’t perform that action at this time.
0 commit comments