okami.mom/strata
git clone https://git.nkp.pet/okami.mom/strata
8ea5361bf
main
1"""A card that works alone but cannot share a model (under 7.5 GB) beside a bigger NVIDIA card: setup says it is not used (a line, no question, no 2change to which cards run). Fake cards through setup.main (tools/test_setup_golden.py's harness).""" 3from __future__import annotations 4 5import sys 6import unittest 7from pathlib import Path 8 9sys .path .insert (0 ,str (Path (__file__ ).resolve ().parents [1 ])) 10sys .path .insert (0 ,str (Path (__file__ ).resolve ().parent )) 11from test_setup_golden import install ,argv_for # noqa: E402 12 13 14def card (i ,name ,gb ,arch = "86" ): 15return {"index" :i ,"name" :name ,"vram_gb" :gb ,"arch" :arch ,"driver" :"580.97" } 16 17 18BIG = card (0 ,"NVIDIA GeForce RTX 4090" ,24.0 ,"89" ) 19SMALL = card (1 ,"NVIDIA GeForce RTX 2060" ,5.9 ,"75" ) 20 21 22class SmallCardSaid (unittest .TestCase ): 23def run_it (self ,found ,extra = ()): 24code ,out ,cfg ,asked = install (256.0 ,found ,argv_for ("qwen" ,"IQ3_S" )+ ["--yes" ,* extra ]) 25self .assertEqual (code ,0 ,out ) 26return out ,cfg ,asked 27 28def test_the_small_card_is_named_with_the_reason (self ): 29out ,cfg ,asked = self .run_it ([BIG ,SMALL ]) 30self .assertIn ("GPU 1 (NVIDIA GeForce RTX 2060, 6 GB) is not used" ,out ) 31self .assertIn ("needs 8 GB or more" ,out ) 32self .assertIn ("runs on GPU 0 alone" ,out ) 33self .assertEqual (asked , [])# printed only 34self .assertEqual ((cfg ["gpu" ],cfg ["gpus_asked" ]), (0 ,True ))# the cards used are what they were 35 36def test_the_small_card_listed_first (self ): 37out ,cfg ,_ = self .run_it ([card (0 ,"NVIDIA GeForce RTX 2060" ,5.9 ,"75" ),card (1 ,"NVIDIA GeForce RTX 4090" ,24.0 ,"89" )]) 38self .assertIn ("GPU 0 (NVIDIA GeForce RTX 2060, 6 GB) is not used" ,out ) 39self .assertEqual (cfg ["gpu" ],1 ) 40 41def test_nothing_is_said_where_nothing_is_left_out (self ): 42for found in ([BIG ], [BIG ,card (1 ,"NVIDIA GeForce RTX 3060" ,12.0 )], [BIG ,card (1 ,"NVIDIA GeForce RTX 3070" ,8.0 )]): 43out ,_cfg ,_ = self .run_it (found ) 44self .assertNotIn ("is not used" ,out ,found ) 45 46def test_naming_a_card_says_nothing_extra (self ): 47out ,cfg ,_ = self .run_it ([BIG ,SMALL ], ["--gpu" ,"0" ]) 48self .assertNotIn ("is not used" ,out ) 49self .assertEqual (cfg ["gpu" ],0 ) 50 51 52if __name__ == "__main__" : 53unittest .main ()