okami.mom/strata

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

Niko1221Merge branch 'f-142-small' into f-142f5aa356f1

main
2.0 KiB53 linesraw
1"""#1485: the card an engine update compiles for is one the installed models use (and CUDA 13 can compile for), not
2the card with the most VRAM - a Tesla V100 beside two RTX 4090s made ./update.sh build for sm_70 with CUDA 13.
3
4    python -m unittest tools.test_setup_update_gpu -v
5"""
6import json
7import sys
8import tempfile
9import unittest
10from pathlib import Path
11from unittest import mock
12
13sys.path.insert(0, str(Path(__file__).resolve().parents[1]))
14import setup  # noqa: E402
15
16V100 = {"index": 1, "name": "Tesla V100-PCIE-32GB", "vram_gb": 32.0, "arch": "70", "driver": "580"}
17R4090 = lambda i: {"index": i, "name": "RTX 4090", "vram_gb": 24.0, "arch": "89", "driver": "580"}  # noqa: E731
18
19
20class UpdateEngineGpu(unittest.TestCase):
21    def pick(self, found, configs, toolkit=13, pinned=None):
22        tmp = tempfile.TemporaryDirectory()
23        self.addCleanup(tmp.cleanup)
24        paths = []
25        for n, cfg in enumerate(configs):
26            p = Path(tmp.name) / f"strata-{n}.json"
27            p.write_text(json.dumps(cfg))
28            paths.append(p)
29        with mock.patch.object(setup, "gpus", return_value=found), \
30                mock.patch.object(setup, "installed_configs", return_value=paths), \
31                mock.patch.object(setup, "GPU_PICK", pinned):
32            return setup.update_engine_gpu(toolkit)
33
34    def test_the_models_cards_not_the_biggest_one(self):
35        g = self.pick([R4090(0), V100, R4090(2)], [{"exe": "x", "args": [], "gpu": [0, 2]}])
36        self.assertEqual(g["arch"], "89")
37        self.assertEqual(g["count"], 3)
38
39    def test_a_card_cuda_13_cannot_compile_for_is_left_out_without_a_config(self):
40        self.assertEqual(self.pick([R4090(0), V100], [])["index"], 0)
41
42    def test_the_cuda_12_engine_may_take_the_volta(self):
43        self.assertEqual(self.pick([R4090(0), V100], [], toolkit=12)["index"], 1)
44
45    def test_only_a_volta_is_still_taken(self):
46        self.assertEqual(self.pick([V100], [])["index"], 1)
47
48    def test_no_nvidia_card(self):
49        self.assertIsNone(self.pick([], []))
50
51
52if __name__ == "__main__":
53    unittest.main()