From 72111c597d4af4619033140d7c7d7839a45eb1d4 Mon Sep 17 00:00:00 2001 From: Ettore Di Giacinto Date: Sat, 3 May 2025 19:00:24 +0200 Subject: [PATCH] fix(gpu): do not assume gpu being returned has node and mem (#5310) Signed-off-by: Ettore Di Giacinto --- core/config/gguf.go | 2 +- pkg/xsysinfo/gpu.go | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/core/config/gguf.go b/core/config/gguf.go index 1c8db29c..99be69be 100644 --- a/core/config/gguf.go +++ b/core/config/gguf.go @@ -170,7 +170,7 @@ func guessGGUFFromFile(cfg *BackendConfig, f *gguf.GGUFFile, defaultCtx int) { vram, err := xsysinfo.TotalAvailableVRAM() if err != nil { log.Error().Msgf("guessDefaultsFromFile(TotalAvailableVRAM): %s", err) - } else { + } else if vram > 0 { estimate, err := xsysinfo.EstimateGGUFVRAMUsage(f, vram) if err != nil { log.Error().Msgf("guessDefaultsFromFile(EstimateGGUFVRAMUsage): %s", err) diff --git a/pkg/xsysinfo/gpu.go b/pkg/xsysinfo/gpu.go index 9a70e17b..17b2ec78 100644 --- a/pkg/xsysinfo/gpu.go +++ b/pkg/xsysinfo/gpu.go @@ -24,8 +24,10 @@ func TotalAvailableVRAM() (uint64, error) { var totalVRAM uint64 for _, gpu := range gpus { - if gpu.Node.Memory.TotalUsableBytes > 0 { - totalVRAM += uint64(gpu.Node.Memory.TotalUsableBytes) + if gpu != nil && gpu.Node != nil && gpu.Node.Memory != nil { + if gpu.Node.Memory.TotalUsableBytes > 0 { + totalVRAM += uint64(gpu.Node.Memory.TotalUsableBytes) + } } }