Skip to content

Commit a8e73c2

Browse files
authored
Add test to check actual get temperature API on device (#41)
1 parent d550857 commit a8e73c2

1 file changed

Lines changed: 22 additions & 0 deletions

File tree

‎tests/test_thermovision.py‎

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,12 @@
55
from typing import Any
66
from unittest.mock import patch
77

8+
import pytest
89
import torch
910

1011
import nsight
1112
from nsight import collection
13+
from nsight.thermovision import CUDA_CORE_AVAILABLE
1214

1315
# ============================================================================
1416
# Thermovision integration tests
@@ -258,3 +260,23 @@ def mock_temp() -> int:
258260
assert (
259261
controller.thermal_cont == 30
260262
), f"Fixed mode should not adapt, but got {controller.thermal_cont}"
263+
264+
265+
@pytest.mark.skipif( # type: ignore[untyped-decorator]
266+
not CUDA_CORE_AVAILABLE, reason="cuda.core required for real device access"
267+
)
268+
def test_get_gpu_temp_real_device() -> None:
269+
"""Test that _get_gpu_temp reads an actual temperature from the GPU device."""
270+
from nsight.thermovision import ThermalController
271+
272+
controller = ThermalController(thermal_mode="off", verbose=False)
273+
supported = controller.init()
274+
275+
if not supported:
276+
pytest.skip("GPU does not support temperature retrieval on this machine")
277+
278+
temp = controller._get_gpu_temp()
279+
280+
assert isinstance(temp, int), f"Expected int temperature, got {type(temp)}"
281+
assert temp >= 0, f"GPU temperature {temp}°C is below 0"
282+
assert temp <= 120, f"GPU temperature {temp}°C is above 120"

0 commit comments

Comments
 (0)