Skip to content

Commit 51e0b5b

Browse files
committed
Handle nvml.NotSupportedError on tests
1 parent 563cd83 commit 51e0b5b

1 file changed

Lines changed: 8 additions & 2 deletions

File tree

cuda_bindings/tests/nvml/test_pynvml.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -137,13 +137,19 @@ def test_device_get_p2p_status(handles, index):
137137

138138
def test_device_get_power_usage(ngpus, handles):
139139
for i in range(ngpus):
140-
power_mwatts = nvml.device_get_power_usage(handles[i])
140+
try:
141+
power_mwatts = nvml.device_get_power_usage(handles[i])
142+
except nvml.NotSupportedError:
143+
pytest.skip("device_get_power_usage not supported")
141144
assert power_mwatts >= 0.0
142145

143146

144147
def test_device_get_total_energy_consumption(ngpus, handles):
145148
for i in range(ngpus):
146-
energy_mjoules1 = nvml.device_get_total_energy_consumption(handles[i])
149+
try:
150+
energy_mjoules1 = nvml.device_get_total_energy_consumption(handles[i])
151+
except nvml.NotSupportedError:
152+
pytest.skip("device_get_total_energy_consumption not supported")
147153
for j in range(10): # idle for 150 ms
148154
time.sleep(0.015) # and check for increase every 15 ms
149155
energy_mjoules2 = nvml.device_get_total_energy_consumption(handles[i])

0 commit comments

Comments
 (0)