|
5 | 5 | from typing import Any |
6 | 6 | from unittest.mock import patch |
7 | 7 |
|
| 8 | +import pytest |
8 | 9 | import torch |
9 | 10 |
|
10 | 11 | import nsight |
11 | 12 | from nsight import collection |
| 13 | +from nsight.thermovision import CUDA_CORE_AVAILABLE |
12 | 14 |
|
13 | 15 | # ============================================================================ |
14 | 16 | # Thermovision integration tests |
@@ -258,3 +260,23 @@ def mock_temp() -> int: |
258 | 260 | assert ( |
259 | 261 | controller.thermal_cont == 30 |
260 | 262 | ), 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