okami.mom/strata

git clone https://git.nkp.pet/okami.mom/strata

Niko1221Merge branch 'f-split-int' into f-split-vision7c5e84612

main
2.7 KiB56 linesraw
1"""`strata launch` on a computer whose only NVIDIA cards are Pascal / Volta (P100, V100): setup.py admits them (the experimental CUDA 12 engine);
2the screens must not say "no usable graphics card found", and several of them must offer the Cards step."""
3
4from __future__ import annotations
5
6import unittest
7from unittest import mock
8
9from strata_cli.launch.catalog import Catalog
10from tests.terminal.launch_support import HW_12, Home, catalog
11
12
13def v100(index: int, vram: float = 16.0) -> dict:
14    return {"index": index, "name": "Tesla V100-SXM2-16GB", "arch": "70", "vram_gb": vram, "vendor": "nvidia", "usable": False,
15            "problem": "not supported - older than the RTX 20 series (compute capability 7.0)"}
16
17
18RTX = {"index": 0, "name": "NVIDIA GeForce RTX 3060", "arch": "86", "vram_gb": 12.0, "vendor": "nvidia", "usable": True, "problem": None}
19
20
21class OldNvidiaCards(unittest.TestCase):
22    def test_only_volta_cards_are_admitted(self):
23        got = Catalog._admit_old_nvidia([v100(0), v100(1)])
24        self.assertEqual([g["usable"] for g in got], [True, True])
25        self.assertTrue(all(g["problem"] is None for g in got))
26
27    def test_a_newer_card_keeps_the_old_one_out(self):
28        got = Catalog._admit_old_nvidia([{**RTX}, v100(1)])
29        self.assertEqual([g["usable"] for g in got], [True, False])
30
31    def test_an_amd_card_keeps_the_old_one_out(self):
32        amd = {"index": 0, "name": "AMD Radeon RX 9070 XT", "vendor": "amd", "usable": True, "vram_gb": 16.0}
33        got = Catalog._admit_old_nvidia([amd, v100(0)])
34        self.assertEqual([g["usable"] for g in got], [True, False])
35
36    def test_other_cards_are_not_touched(self):
37        gtx = {"index": 0, "name": "GeForce GT 1030", "arch": "61", "vram_gb": 2.0, "vendor": "nvidia", "usable": False}
38        self.assertEqual(Catalog._admit_old_nvidia([gtx])[0]["usable"], True)    # Pascal is admitted too (setup does the same)
39        kepler = {"index": 0, "name": "Tesla K80", "arch": "37", "vram_gb": 12.0, "vendor": "nvidia", "usable": False}
40        self.assertEqual(Catalog._admit_old_nvidia([kepler])[0]["usable"], False)
41        self.assertEqual(Catalog._admit_old_nvidia([]), [])
42
43    def test_hardware_and_computer_show_the_cards(self):
44        with Home():
45            cat = catalog()
46            cat._hardware_override = None
47            hw = {**HW_12, "gpus": [v100(0), v100(1)]}
48            with mock.patch.object(type(cat.strata), "hardware", return_value=hw):
49                comp = cat.computer(fresh=True)
50            self.assertEqual(len(comp.usable_gpus), 2)
51            self.assertIn("x2", comp.line())
52            self.assertNotIn("no usable graphics card", comp.line())
53
54
55if __name__ == "__main__":
56    unittest.main()