mirror of
https://github.com/mudler/LocalAI.git
synced 2026-05-18 13:38:49 -04:00
feat(backends): add system backend, refactor (#6059)
- Add a system backend path - Refactor and consolidate system information in system state - Use system state in all the components to figure out the system paths to used whenever needed - Refactor BackendConfig -> ModelConfig. This was otherway misleading as now we do have a backend configuration which is not the model config. Signed-off-by: Ettore Di Giacinto <mudler@localai.io>
This commit is contained in:
committed by
GitHub
parent
253b7537dc
commit
089efe05fd
@@ -6,16 +6,9 @@ import (
|
||||
"strings"
|
||||
|
||||
"github.com/jaypipes/ghw/pkg/gpu"
|
||||
"github.com/mudler/LocalAI/pkg/xsysinfo"
|
||||
"github.com/rs/zerolog/log"
|
||||
)
|
||||
|
||||
type SystemState struct {
|
||||
GPUVendor string
|
||||
gpus []*gpu.GraphicsCard
|
||||
VRAM uint64
|
||||
}
|
||||
|
||||
const (
|
||||
defaultCapability = "default"
|
||||
nvidiaL4T = "nvidia-l4t"
|
||||
@@ -103,22 +96,6 @@ func (s *SystemState) getSystemCapabilities() string {
|
||||
return s.GPUVendor
|
||||
}
|
||||
|
||||
func GetSystemState() (*SystemState, error) {
|
||||
// Detection is best-effort here, we don't want to fail if it fails
|
||||
gpus, _ := xsysinfo.GPUs()
|
||||
log.Debug().Any("gpus", gpus).Msg("GPUs")
|
||||
gpuVendor, _ := detectGPUVendor(gpus)
|
||||
log.Debug().Str("gpuVendor", gpuVendor).Msg("GPU vendor")
|
||||
vram, _ := xsysinfo.TotalAvailableVRAM()
|
||||
log.Debug().Any("vram", vram).Msg("Total available VRAM")
|
||||
|
||||
return &SystemState{
|
||||
GPUVendor: gpuVendor,
|
||||
gpus: gpus,
|
||||
VRAM: vram,
|
||||
}, nil
|
||||
}
|
||||
|
||||
func detectGPUVendor(gpus []*gpu.GraphicsCard) (string, error) {
|
||||
for _, gpu := range gpus {
|
||||
if gpu.DeviceInfo != nil {
|
||||
|
||||
Reference in New Issue
Block a user