mirror of
https://github.com/LostRuins/koboldcpp.git
synced 2026-09-18 16:55:14 +02:00
fix exception on exit
This commit is contained in:
+43
-40
@@ -8357,49 +8357,52 @@ def show_gui():
|
||||
# run in new thread so it doesnt block. does not return anything, instead overwrites specific values and redraws GUI
|
||||
def auto_set_backend_gui(manual_select=False):
|
||||
global exitcounter, runmode_untouched
|
||||
if manual_select:
|
||||
print("\nA .kcppt template was selected from GUI - automatically selecting your backend...")
|
||||
runmode_untouched = True
|
||||
fetch_gpu_properties(True,True)
|
||||
found_new_backend = False
|
||||
try:
|
||||
if manual_select:
|
||||
print("\nA .kcppt template was selected from GUI - automatically selecting your backend...")
|
||||
runmode_untouched = True
|
||||
fetch_gpu_properties(True,True)
|
||||
found_new_backend = False
|
||||
|
||||
# check for avx2 and avx support
|
||||
is_oldpc_ver = "Use CPU" not in runopts #on oldcpu ver, default lib does not exist
|
||||
cpusupport = old_cpu_check() # 0 if has avx2, 1 if has avx, 2 if has nothing
|
||||
eligible_cuda = (cpusupport<1 and not is_oldpc_ver) or (cpusupport<2 and is_oldpc_ver)
|
||||
# check for avx2 and avx support
|
||||
is_oldpc_ver = "Use CPU" not in runopts #on oldcpu ver, default lib does not exist
|
||||
cpusupport = old_cpu_check() # 0 if has avx2, 1 if has avx, 2 if has nothing
|
||||
eligible_cuda = (cpusupport<1 and not is_oldpc_ver) or (cpusupport<2 and is_oldpc_ver)
|
||||
|
||||
#autopick cublas if suitable, requires at least 3.5GB VRAM to auto pick
|
||||
#we do not want to autoselect hip/cublas if the user has already changed their desired backend!
|
||||
if eligible_cuda and exitcounter < 100 and MaxMemory[0]>3500000000 and runmode_untouched and (("Use CUDA" in runopts and CUDevicesNames[0]!="") or "Use hipBLAS (ROCm)" in runopts) and (any(CUDevicesNames)):
|
||||
if "Use CUDA" in runopts:
|
||||
runopts_var.set("Use CUDA")
|
||||
gpu_choice_var.set("0")
|
||||
print(f"Auto Selected CUDA Backend (flag={cpusupport})\n")
|
||||
found_new_backend = True
|
||||
elif "Use hipBLAS (ROCm)" in runopts:
|
||||
runopts_var.set("Use hipBLAS (ROCm)")
|
||||
gpu_choice_var.set("0")
|
||||
print(f"Auto Selected HIP Backend (flag={cpusupport})\n")
|
||||
found_new_backend = True
|
||||
elif exitcounter < 100 and (1 in VKIsDGPU) and runmode_untouched and ("Use Vulkan" in runopts or "Use Vulkan (Old CPU)" in runopts):
|
||||
for i in range(0,len(VKIsDGPU)):
|
||||
if VKIsDGPU[i]==1:
|
||||
if cpusupport<1 and "Use Vulkan" in runopts:
|
||||
runopts_var.set("Use Vulkan")
|
||||
else:
|
||||
runopts_var.set("Use Vulkan (Old CPU)")
|
||||
gpu_choice_var.set(str(i))
|
||||
print(f"Auto Selected Vulkan Backend (flag={cpusupport})\n")
|
||||
#autopick cublas if suitable, requires at least 3.5GB VRAM to auto pick
|
||||
#we do not want to autoselect hip/cublas if the user has already changed their desired backend!
|
||||
if eligible_cuda and exitcounter < 100 and MaxMemory[0]>3500000000 and runmode_untouched and (("Use CUDA" in runopts and CUDevicesNames[0]!="") or "Use hipBLAS (ROCm)" in runopts) and (any(CUDevicesNames)):
|
||||
if "Use CUDA" in runopts:
|
||||
runopts_var.set("Use CUDA")
|
||||
gpu_choice_var.set("0")
|
||||
print(f"Auto Selected CUDA Backend (flag={cpusupport})\n")
|
||||
found_new_backend = True
|
||||
break
|
||||
else:
|
||||
if runopts_var.get()=="Use CPU" and cpusupport==1 and "Use CPU (Old CPU)" in runopts:
|
||||
runopts_var.set("Use CPU (Old CPU)")
|
||||
elif runopts_var.get()=="Use CPU" and cpusupport==2 and "Failsafe Mode (Older CPU)" in runopts:
|
||||
runopts_var.set("Failsafe Mode (Older CPU)")
|
||||
if not found_new_backend:
|
||||
print(f"Auto Selected Default Backend (flag={cpusupport})\n")
|
||||
changed_gpu_choice_var()
|
||||
elif "Use hipBLAS (ROCm)" in runopts:
|
||||
runopts_var.set("Use hipBLAS (ROCm)")
|
||||
gpu_choice_var.set("0")
|
||||
print(f"Auto Selected HIP Backend (flag={cpusupport})\n")
|
||||
found_new_backend = True
|
||||
elif exitcounter < 100 and (1 in VKIsDGPU) and runmode_untouched and ("Use Vulkan" in runopts or "Use Vulkan (Old CPU)" in runopts):
|
||||
for i in range(0,len(VKIsDGPU)):
|
||||
if VKIsDGPU[i]==1:
|
||||
if cpusupport<1 and "Use Vulkan" in runopts:
|
||||
runopts_var.set("Use Vulkan")
|
||||
else:
|
||||
runopts_var.set("Use Vulkan (Old CPU)")
|
||||
gpu_choice_var.set(str(i))
|
||||
print(f"Auto Selected Vulkan Backend (flag={cpusupport})\n")
|
||||
found_new_backend = True
|
||||
break
|
||||
else:
|
||||
if runopts_var.get()=="Use CPU" and cpusupport==1 and "Use CPU (Old CPU)" in runopts:
|
||||
runopts_var.set("Use CPU (Old CPU)")
|
||||
elif runopts_var.get()=="Use CPU" and cpusupport==2 and "Failsafe Mode (Older CPU)" in runopts:
|
||||
runopts_var.set("Failsafe Mode (Older CPU)")
|
||||
if not found_new_backend:
|
||||
print(f"Auto Selected Default Backend (flag={cpusupport})\n")
|
||||
changed_gpu_choice_var()
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
def on_picked_model_file(filepath):
|
||||
if filepath and (filepath.lower().endswith('.kcpps') or filepath.lower().endswith('.kcppt')):
|
||||
|
||||
Reference in New Issue
Block a user