Get up and running with Kimi, GLM, MiniMax, DeepSeek, gpt-oss, Qwen, Gemma and other models.
darwin: no partial offloading if required memory greater than system
Michael Yang41a272de9fd2
diff --git a/gpu/gpu_darwin.go b/gpu/gpu_darwin.goindex 824f43bf6..39e257e4d 100644--- a/gpu/gpu_darwin.go+++ b/gpu/gpu_darwin.go@@ -32,6 +32,7 @@ func CheckVRAM() (uint64, error) {// gpu not supported, this may not be metalreturn 0, nil}+return uint64(C.getRecommendedMaxVRAM()), nil}@@ -52,7 +53,7 @@ func GetGPUInfo() GpuInfo {func getCPUMem() (memInfo, error) {return memInfo{- TotalMemory: 0,+ TotalMemory: uint64(C.getPhysicalMemory()),FreeMemory: 0,DeviceCount: 0,}, nildiff --git a/gpu/gpu_info_darwin.h b/gpu/gpu_info_darwin.hindex 6ba30c0a5..3edca237c 100644--- a/gpu/gpu_info_darwin.h+++ b/gpu/gpu_info_darwin.h@@ -1,3 +1,4 @@#import <Metal/Metal.h>#include <stdint.h>uint64_t getRecommendedMaxVRAM();+uint64_t getPhysicalMemory();diff --git a/gpu/gpu_info_darwin.m b/gpu/gpu_info_darwin.mindex 06d7b69ba..a145ac076 100644--- a/gpu/gpu_info_darwin.m+++ b/gpu/gpu_info_darwin.m@@ -1,11 +1,13 @@-//go:build darwin+// go:build darwin#include "gpu_info_darwin.h"-uint64_t getRecommendedMaxVRAM()-{- id<MTLDevice> device = MTLCreateSystemDefaultDevice();- uint64_t result = device.recommendedMaxWorkingSetSize;- CFRelease(device);- return result;+uint64_t getRecommendedMaxVRAM() {+ id<MTLDevice> device = MTLCreateSystemDefaultDevice();+ uint64_t result = device.recommendedMaxWorkingSetSize;+ CFRelease(device);+ return result;}+uint64_t getPhysicalMemory() {+ return [[NSProcessInfo processInfo] physicalMemory];+}diff --git a/llm/server.go b/llm/server.goindex 4c1f96346..0bbdebce3 100644--- a/llm/server.go+++ b/llm/server.go@@ -108,7 +108,11 @@ func NewLlamaServer(model string, adapters, projectors []string, opts api.OptionmemoryLayerOutput := layers["output"].size()memoryRequiredTotal += memoryLayerOutput- if memoryAvailable > memoryRequiredTotal {++ if info.Library == "metal" && memoryRequiredTotal > info.TotalMemory {+ // disable partial offloading when model is greater than total system memory+ opts.NumGPU = 0+ } else if memoryAvailable > memoryRequiredTotal {layerCount = int(ggml.KV().BlockCount()) + 1memoryRequiredPartial = memoryRequiredTotal}