LocalAI/core/system/capabilities.go
Ettore Di Giacinto 9a34fc8c66 feat(backend gallery): add meta packages
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>
2025-06-20 22:08:12 +02:00

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
}