mirror of
https://github.com/mudler/LocalAI.git
synced 2025-06-23 19:24:59 +00:00

So we can have meta packages such as "vllm" that automatically installs the corresponding package depending on the GPU that is being currently detected in the system. Signed-off-by: Ettore Di Giacinto <mudler@localai.io>
40 lines
725 B
Go
40 lines
725 B
Go
package system
|
|
|
|
import (
|
|
"strings"
|
|
|
|
"github.com/mudler/LocalAI/pkg/xsysinfo"
|
|
)
|
|
|
|
type SystemState struct {
|
|
GPUVendor string
|
|
}
|
|
|
|
func GetSystemState() (*SystemState, error) {
|
|
gpuVendor, err := detectGPUVendor()
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return &SystemState{GPUVendor: gpuVendor}, nil
|
|
}
|
|
|
|
func detectGPUVendor() (string, error) {
|
|
gpus, err := xsysinfo.GPUs()
|
|
if err != nil {
|
|
return "", err
|
|
}
|
|
|
|
for _, gpu := range gpus {
|
|
if strings.ToUpper(gpu.DeviceInfo.Vendor.Name) == "NVIDIA" {
|
|
return "nvidia", nil
|
|
}
|
|
if strings.ToUpper(gpu.DeviceInfo.Vendor.Name) == "AMD" {
|
|
return "amd", nil
|
|
}
|
|
if strings.ToUpper(gpu.DeviceInfo.Vendor.Name) == "INTEL" {
|
|
return "intel", nil
|
|
}
|
|
}
|
|
|
|
return "", nil
|
|
}
|