From 2ae6bff5bdf2f918c193d589a7803835d7286ee2 Mon Sep 17 00:00:00 2001 From: Wagner Bruna Date: Mon, 10 Nov 2025 07:07:15 -0300 Subject: [PATCH] split memory detection functions and add debug command (#1832) --- koboldcpp.py | 60 ++++++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 49 insertions(+), 11 deletions(-) diff --git a/koboldcpp.py b/koboldcpp.py index ff6019c60..5a621185d 100644 --- a/koboldcpp.py +++ b/koboldcpp.py @@ -1195,11 +1195,7 @@ def autoset_gpu_layers(ctxsize, sdquanted, bbs, qkv_level): #shitty algo to dete except Exception: return 0 -def fetch_gpu_properties(testCL,testCU,testVK): - gpumem_ignore_limit_min = 1024*1024*600 #600 mb min - gpumem_ignore_limit_max = 1024*1024*1024*300 #300 gb max - - if testCU: +def detect_memory_cu(gpumem_ignore_limit_min, gpumem_ignore_limit_max): FetchedCUdevices = [] FetchedCUdeviceMem = [] FetchedCUfreeMem = [] @@ -1276,10 +1272,11 @@ def fetch_gpu_properties(testCL,testCU,testVK): lowestcumem = 0 lowestfreecumem = 0 - MaxMemory[0] = max(lowestcumem,MaxMemory[0]) - MaxFreeMemory[0] = max(lowestfreecumem,MaxFreeMemory[0]) + return lowestcumem, lowestfreecumem + + +def detect_memory_vk(gpumem_ignore_limit_min, gpumem_ignore_limit_max): - if testVK: try: # Get Vulkan names foundVkGPU = False lowestvkmem = 0 @@ -1318,11 +1315,15 @@ def fetch_gpu_properties(testCL,testCU,testVK): gpuidx += 1 except Exception: # failed to get vulkan vram pass - MaxMemory[0] = max(lowestvkmem,MaxMemory[0]) + return lowestvkmem except Exception: pass - if testCL: + return 0 + + +def detect_memory_cl(gpumem_ignore_limit_min, gpumem_ignore_limit_max): + try: # Get OpenCL GPU names on windows using a special binary. overwrite at known index if found. basepath = os.path.abspath(os.path.dirname(__file__)) output = "" @@ -1348,10 +1349,40 @@ def fetch_gpu_properties(testCL,testCU,testVK): lowestclmem = dmem if lowestclmem==0 else (dmem if dmem