Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions tests/test_gpu.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,15 @@ def test_snapshot_gpu_name_is_string(self):
snapshot = monitor.snapshot()
self.assertIsInstance(snapshot["gpu_name"], str)

def test_snapshot_vram_values_are_numeric(self):
def test_snapshot_vram_values_are_numeric_or_none(self):
# ``None`` is a valid response when neither torch.cuda nor
# nvidia-smi can answer — we deliberately don't fall back to
# system RAM via psutil any more (would mislead the safety
# estimator). Numeric otherwise.
monitor = GPUMonitor()
snapshot = monitor.snapshot()
self.assertIsInstance(snapshot["vram_total_gb"], (int, float))
self.assertIsInstance(snapshot["vram_used_gb"], (int, float))
self.assertIsInstance(snapshot["vram_total_gb"], (int, float, type(None)))
self.assertIsInstance(snapshot["vram_used_gb"], (int, float, type(None)))


class GPUMonitorNvidiaTests(unittest.TestCase):
Expand Down