okami.mom/strata
git clone https://git.nkp.pet/okami.mom/strata
f5aa356f1
main
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 4python -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 ): 21def pick (self ,found ,configs ,toolkit = 13 ,pinned = None ): 22tmp = tempfile .TemporaryDirectory () 23self .addCleanup (tmp .cleanup ) 24paths = [] 25for n ,cfg in enumerate (configs ): 26p = Path (tmp .name )/ f"strata- { n } .json" 27p .write_text (json .dumps (cfg )) 28paths .append (p ) 29with mock .patch .object (setup ,"gpus" ,return_value = found ), \ 30mock .patch .object (setup ,"installed_configs" ,return_value = paths ), \ 31mock .patch .object (setup ,"GPU_PICK" ,pinned ): 32return setup .update_engine_gpu (toolkit ) 33 34def test_the_models_cards_not_the_biggest_one (self ): 35g = self .pick ([R4090 (0 ),V100 ,R4090 (2 )], [{"exe" :"x" ,"args" : [],"gpu" : [0 ,2 ]}]) 36self .assertEqual (g ["arch" ],"89" ) 37self .assertEqual (g ["count" ],3 ) 38 39def test_a_card_cuda_13_cannot_compile_for_is_left_out_without_a_config (self ): 40self .assertEqual (self .pick ([R4090 (0 ),V100 ], [])["index" ],0 ) 41 42def test_the_cuda_12_engine_may_take_the_volta (self ): 43self .assertEqual (self .pick ([R4090 (0 ),V100 ], [],toolkit = 12 )["index" ],1 ) 44 45def test_only_a_volta_is_still_taken (self ): 46self .assertEqual (self .pick ([V100 ], [])["index" ],1 ) 47 48def test_no_nvidia_card (self ): 49self .assertIsNone (self .pick ([], [])) 50 51 52if __name__ == "__main__" : 53unittest .main ()