Skip to content

Commit f208670

Browse files
committed
improve error handling with gpu names
1 parent 860e738 commit f208670

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

koboldcpp.py

+7-4
Original file line numberDiff line numberDiff line change
@@ -729,14 +729,15 @@ def getfilename(var, text):
729729
button.grid(row=row+1, column=1, stick="nw")
730730
return
731731

732-
from subprocess import run
732+
from subprocess import run, CalledProcessError
733733
def get_device_names():
734734
CUdevices = []
735735
CLdevices = []
736736
try: # Get OpenCL GPU names
737737
output = run(['clinfo'], capture_output=True, text=True, check=True, encoding='utf-8').stdout
738738
CLdevices = [line.split(":", 1)[1].strip() for line in output.splitlines() if line.strip().startswith("Board name:")]
739-
except FileNotFoundError: pass
739+
except Exception as e:
740+
pass
740741
try: # Get AMD ROCm GPU names
741742
output = run(['rocminfo'], capture_output=True, text=True, check=True, encoding='utf-8').stdout
742743
device_name = None
@@ -745,12 +746,14 @@ def get_device_names():
745746
if line.startswith("Marketing Name:"): device_name = line.split(":", 1)[1].strip()
746747
elif line.startswith("Device Type:") and "GPU" in line and device_name is not None: CUdevices.append(device_name)
747748
elif line.startswith("Device Type:") and "GPU" not in line: device_name = None
748-
except FileNotFoundError: pass
749+
except Exception as e:
750+
pass
749751
# try: # Get NVIDIA GPU names , Couldn't test so probably not working yet.
750752
# output = run(['nvidia-smi', '-L'], capture_output=True, text=True, check=True, encoding='utf-8').stdout
751753
# CUdevices = [line.split(":", 1)[1].strip() for line in output.splitlines() if line.startswith("GPU:")]
752754
# except FileNotFoundError: pass
753-
if CUdevices: CUdevices.append('All')
755+
CUdevices.append('All') if CUdevices else CUdevices.extend(['1', '2', '3', 'All'])
756+
if not CLdevices: CLdevices.extend(['1', '2', '3'])
754757
return CUdevices, CLdevices
755758

756759
# Vars - should be in scope to be used by multiple widgets

0 commit comments

Comments
 (0)