From 6df83e6daac96e4fdfb04bec8d36840f5b660a0c Mon Sep 17 00:00:00 2001 From: Jeffrey Morgan Date: Tue, 9 Jan 2024 11:47:30 -0500 Subject: [PATCH] update rough cuda overhead estimate to 15% + 384MiB --- gpu/gpu.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/gpu/gpu.go b/gpu/gpu.go index 5bc1810e..cbe0ed94 100644 --- a/gpu/gpu.go +++ b/gpu/gpu.go @@ -131,8 +131,12 @@ func getCPUMem() (memInfo, error) { func CheckVRAM() (int64, error) { gpuInfo := GetGPUInfo() if gpuInfo.FreeMemory > 0 && (gpuInfo.Library == "cuda" || gpuInfo.Library == "rocm") { - // leave 20% of VRAM free for unaccounted for overhead - return int64(gpuInfo.FreeMemory * 4 / 5), nil + // leave 10% or 384Mi of VRAM free for unaccounted for overhead + overhead := gpuInfo.FreeMemory / 10 + if overhead < 384*1024*1024 { + overhead = 384 * 1024 * 1024 + } + return int64(gpuInfo.FreeMemory - overhead), nil } return 0, fmt.Errorf("no GPU detected") // TODO - better handling of CPU based memory determiniation