mirror of
https://github.com/mudler/LocalAI.git
synced 2026-04-14 12:02:23 -04:00
* 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> * feat: use a metadata file Signed-off-by: Ettore Di Giacinto <mudler@localai.io> --------- Signed-off-by: Ettore Di Giacinto <mudler@localai.io>
50 lines
874 B
Go
50 lines
874 B
Go
package system
|
|
|
|
import (
|
|
"strings"
|
|
|
|
"github.com/mudler/LocalAI/pkg/xsysinfo"
|
|
"github.com/rs/zerolog/log"
|
|
)
|
|
|
|
type SystemState struct {
|
|
GPUVendor string
|
|
}
|
|
|
|
func GetSystemState() (*SystemState, error) {
|
|
gpuVendor, _ := detectGPUVendor()
|
|
log.Debug().Str("gpuVendor", gpuVendor).Msg("GPU vendor")
|
|
|
|
return &SystemState{
|
|
GPUVendor: gpuVendor,
|
|
}, nil
|
|
}
|
|
|
|
func detectGPUVendor() (string, error) {
|
|
gpus, err := xsysinfo.GPUs()
|
|
if err != nil {
|
|
return "", err
|
|
}
|
|
|
|
for _, gpu := range gpus {
|
|
if gpu.DeviceInfo != nil {
|
|
if gpu.DeviceInfo.Vendor != nil {
|
|
gpuVendorName := strings.ToUpper(gpu.DeviceInfo.Vendor.Name)
|
|
if gpuVendorName == "NVIDIA" {
|
|
return "nvidia", nil
|
|
}
|
|
if gpuVendorName == "AMD" {
|
|
return "amd", nil
|
|
}
|
|
if gpuVendorName == "INTEL" {
|
|
return "intel", nil
|
|
}
|
|
return "nvidia", nil
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
return "", nil
|
|
}
|