Get up and running with Kimi, GLM, MiniMax, DeepSeek, gpt-oss, Qwen, Gemma and other models.
Allow setting max vram for workarounds
Daniel Hiltgenbe330174dd71
diff --git a/gpu/gpu.go b/gpu/gpu.goindex b5baff38c..8c7f12979 100644--- a/gpu/gpu.go+++ b/gpu/gpu.go@@ -242,6 +242,15 @@ func getCPUMem() (memInfo, error) {}func CheckVRAM() (int64, error) {+ userLimit := os.Getenv("OLLAMA_MAX_VRAM")+ if userLimit != "" {+ avail, err := strconv.ParseInt(userLimit, 10, 64)+ if err != nil {+ return 0, fmt.Errorf("Invalid OLLAMA_MAX_VRAM setting %s: %s", userLimit, err)+ }+ slog.Info(fmt.Sprintf("user override OLLAMA_MAX_VRAM=%d", avail))+ return avail, nil+ }gpuInfo := GetGPUInfo()if gpuInfo.FreeMemory > 0 && (gpuInfo.Library == "cuda" || gpuInfo.Library == "rocm") {// leave 10% or 1024MiB of VRAM free per GPU to handle unaccounted for overheaddiff --git a/gpu/gpu_darwin.go b/gpu/gpu_darwin.goindex 9a418c0b0..f2856e29c 100644--- a/gpu/gpu_darwin.go+++ b/gpu/gpu_darwin.go@@ -1,6 +1,7 @@//go:build darwinpackage gpu+/*#cgo CFLAGS: -x objective-c#cgo LDFLAGS: -framework Foundation -framework CoreGraphics -framework Metal@@ -8,11 +9,25 @@ package gpu*/import "C"import (+ "fmt"+ "log/slog"+ "os""runtime"+ "strconv")// CheckVRAM returns the free VRAM in bytes on Linux machines with NVIDIA GPUsfunc CheckVRAM() (int64, error) {+ userLimit := os.Getenv("OLLAMA_MAX_VRAM")+ if userLimit != "" {+ avail, err := strconv.ParseInt(userLimit, 10, 64)+ if err != nil {+ return 0, fmt.Errorf("Invalid OLLAMA_MAX_VRAM setting %s: %s", userLimit, err)+ }+ slog.Info(fmt.Sprintf("user override OLLAMA_MAX_VRAM=%d", avail))+ return avail, nil+ }+if runtime.GOARCH == "amd64" {// gpu not supported, this may not be metalreturn 0, nil