11# SPDX-FileCopyrightText: Copyright (c) 2025-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
22# SPDX-License-Identifier: Apache-2.0
33
4- from collections import namedtuple
54
65import pytest
76from cuda_python_test_helpers .arch_check import unsupported_before # noqa: F401
@@ -26,56 +25,19 @@ def nvml_init():
2625 yield
2726
2827
29- @pytest .fixture (scope = "session" , autouse = True )
30- def device_info ():
31- dev_count = None
32- bus_id_to_board_details = {}
33-
34- with NVMLInitializer ():
35- dev_count = nvml .device_get_count_v2 ()
36-
37- # Store some details for each device now when we know NVML is in known state
38- for i in range (dev_count ):
39- try :
40- dev = nvml .device_get_handle_by_index_v2 (i )
41- except nvml .NoPermissionError :
42- continue
43- pci_info = nvml .device_get_pci_info_v3 (dev )
44-
45- name = nvml .device_get_name (dev )
46- # Get architecture name ex: Ampere, Kepler
47- arch_id = nvml .device_get_architecture (dev )
48-
49- BoardCfg = namedtuple ("BoardCfg" , "name, ids_arr" )
50- board = BoardCfg (name , ids_arr = [(pci_info .pci_device_id , pci_info .pci_sub_system_id )])
51-
52- try :
53- serial = nvml .device_get_serial (dev )
54- except nvml .NvmlError :
55- serial = None
56-
57- bus_id = pci_info .bus_id
58- device_id = pci_info .device_
59- uuid = nvml .device_get_uuid (dev )
60-
61- BoardDetails = namedtuple ("BoardDetails" , "name, board, arch_id, bus_id, device_id, serial" )
62- bus_id_to_board_details [uuid ] = BoardDetails (name , board , arch_id , bus_id , device_id , serial )
63-
64- return bus_id_to_board_details
65-
66-
67- def get_devices (device_info ):
68- for uuid in list (device_info .keys ()):
28+ def get_devices ():
29+ dev_count = nvml .device_get_count_v2 ()
30+ for i in range (dev_count ):
6931 try :
70- yield nvml .device_get_handle_by_uuid ( uuid )
32+ yield nvml .device_get_handle_by_index_v2 ( i )
7133 except nvml .NoPermissionError :
7234 continue # ignore devices that can't be accessed
7335
7436
7537@pytest .fixture
76- def all_devices (device_info ):
38+ def all_devices ():
7739 with NVMLInitializer ():
78- yield sorted (set (get_devices (device_info )))
40+ yield sorted (set (get_devices ()))
7941
8042
8143@pytest .fixture
0 commit comments