@@ -39,3 +39,51 @@ def fetch_gpu(log: Logger) -> list[str] | None:
3939 .split ("\n " )
4040 )
4141 ]
42+
43+
44+ def install_gpu_drivers (log : Logger , install_list : list [str ]) -> None :
45+ """Append the appropriate driver in the list for GPU installation.
46+
47+ Args:
48+ log -- instance of Logger
49+
50+ Returns:
51+ true if the GPU was installed successfully or if there is
52+ no driver to install and false if otherwise.
53+ """
54+
55+ #! THIS IS EXPERIMENTAL AND NOT TESTED DUE TO LACK OF HARDWARE
56+ #! SHOULD NOT BE CALLED YET ON THE MAIN FUNCTION IN MAIN.PY
57+ #! ALTHOUGH THIS CAN BE ENABLED USING A FLAG `ex` IN THE CLI
58+ #! BUT NOT IN DEFAULT OPTIONS, DO IT IN YOUR OWN DISCRETION
59+
60+
61+ gpu_list : list [str ] | None = fetch_gpu (log )
62+
63+ if gpu is None :
64+ log .logger (
65+ "I" , "There is no GPU driver to install, skipping ..."
66+ )
67+ return None
68+
69+ gpu_drivers : dict [str | list [str ], list [str ]] = {
70+ "nvidia" : ["akmod-nvidia" , "xorg-x11-drv-nvidia" ],
71+ }
72+
73+ for gpu in gpu_list :
74+ vendor : str ; gpu_info : list [str ] | str
75+ vendor , * gpu_info = gpu
76+
77+ match [vendor , gpu_info ]:
78+ case ["nvidia" , * gpu_info ]:
79+ drv_id : str = "nvidia"
80+ case ["intel" , * gpu_info ]:
81+ ...
82+ case ["advanced micro devices" , * gpu_info ]:
83+ ...
84+ case _:
85+ continue
86+
87+ install_list .extend (gpu_drivers [drv_id ])
88+
89+ return None
0 commit comments