okami.mom/strata
git clone https://git.nkp.pet/okami.mom/strata
7c5e84612
main
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 : 14return {"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 ): 22def test_only_volta_cards_are_admitted (self ): 23got = Catalog ._admit_old_nvidia ([v100 (0 ),v100 (1 )]) 24self .assertEqual ([g ["usable" ]for g in got ], [True ,True ]) 25self .assertTrue (all (g ["problem" ]is None for g in got )) 26 27def test_a_newer_card_keeps_the_old_one_out (self ): 28got = Catalog ._admit_old_nvidia ([{** RTX },v100 (1 )]) 29self .assertEqual ([g ["usable" ]for g in got ], [True ,False ]) 30 31def test_an_amd_card_keeps_the_old_one_out (self ): 32amd = {"index" :0 ,"name" :"AMD Radeon RX 9070 XT" ,"vendor" :"amd" ,"usable" :True ,"vram_gb" :16.0 } 33got = Catalog ._admit_old_nvidia ([amd ,v100 (0 )]) 34self .assertEqual ([g ["usable" ]for g in got ], [True ,False ]) 35 36def test_other_cards_are_not_touched (self ): 37gtx = {"index" :0 ,"name" :"GeForce GT 1030" ,"arch" :"61" ,"vram_gb" :2.0 ,"vendor" :"nvidia" ,"usable" :False } 38self .assertEqual (Catalog ._admit_old_nvidia ([gtx ])[0 ]["usable" ],True )# Pascal is admitted too (setup does the same) 39kepler = {"index" :0 ,"name" :"Tesla K80" ,"arch" :"37" ,"vram_gb" :12.0 ,"vendor" :"nvidia" ,"usable" :False } 40self .assertEqual (Catalog ._admit_old_nvidia ([kepler ])[0 ]["usable" ],False ) 41self .assertEqual (Catalog ._admit_old_nvidia ([]), []) 42 43def test_hardware_and_computer_show_the_cards (self ): 44with Home (): 45cat = catalog () 46cat ._hardware_override = None 47hw = {** HW_12 ,"gpus" : [v100 (0 ),v100 (1 )]} 48with mock .patch .object (type (cat .strata ),"hardware" ,return_value = hw ): 49comp = cat .computer (fresh = True ) 50self .assertEqual (len (comp .usable_gpus ),2 ) 51self .assertIn ("x2" ,comp .line ()) 52self .assertNotIn ("no usable graphics card" ,comp .line ()) 53 54 55if __name__ == "__main__" : 56unittest .main ()