@@ -686,12 +686,21 @@ def show_new_gui():
686
686
687
687
tabcontent = {}
688
688
689
+ lib_option_pairs = [
690
+ (lib_openblas , "Use OpenBLAS" ),
691
+ (lib_clblast , "Use CLBlast" ),
692
+ (lib_cublas , "Use CuBLAS/hipBLAS" ),
693
+ (lib_default , "Use No BLAS" ),
694
+ (lib_openblas_noavx2 , "Use OpenBLAS (Old CPU, noavx2)" ),
695
+ (lib_failsafe , "Failsafe Mode (Old CPU, noavx)" )]
696
+ openblas_option , clblast_option , cublas_option , default_option , openblas_noavx2_option , failsafe_option = (opt if file_exists (lib ) or (os .name == 'nt' and file_exists (opt + ".dll" )) else None for lib , opt in lib_option_pairs )
689
697
# slider data
690
698
blasbatchsize_values = ["-1" , "32" , "64" , "128" , "256" , "512" , "1024" ]
691
699
blasbatchsize_text = ["Don't Batch BLAS" ,"32" ,"64" ,"128" ,"256" ,"512" ,"1024" ]
692
700
contextsize_text = ["512" , "1024" , "2048" , "3072" , "4096" , "6144" , "8192" ]
693
- runopts = ["Use OpenBLAS" ,"Use CLBlast" , "Use CuBLAS/hipBLAS" , "Use No BLAS" ,"Use OpenBLAS (Old CPU, noavx2)" ,"Failsafe Mode (Old CPU, noavx)" ]
694
-
701
+ runopts = [opt for lib , opt in lib_option_pairs if file_exists (lib ) or os .name == 'nt' and file_exists (opt + ".dll" )]
702
+ if not any (runopts ):
703
+ show_gui_warning ("No Backend Available" )
695
704
def tabbuttonaction (name ):
696
705
for t in tabcontent :
697
706
if name == t :
@@ -884,7 +893,7 @@ def changerunmode(a,b,c):
884
893
885
894
runoptbox = ctk .CTkComboBox (quick_tab , values = runopts , width = 180 ,variable = runopts_var , state = "readonly" )
886
895
runoptbox .grid (row = 1 , column = 1 ,padx = 8 , stick = "nw" )
887
- runoptbox .set ("Use OpenBLAS" )
896
+ runoptbox .set (runopts [ 0 ] )
888
897
889
898
# threads
890
899
makelabelentry (quick_tab , "Threads:" , threads_var , 8 , 50 )
@@ -917,7 +926,7 @@ def changerunmode(a,b,c):
917
926
makelabel (hardware_tab , "Presets:" , 1 )
918
927
runoptbox = ctk .CTkComboBox (hardware_tab , values = runopts , width = 180 ,variable = runopts_var , state = "readonly" )
919
928
runoptbox .grid (row = 1 , column = 1 ,padx = 8 , stick = "nw" )
920
- runoptbox .set ("Use OpenBLAS" )
929
+ runoptbox .set (runopts [ 0 ] )
921
930
runopts_var .trace ('w' , changerunmode )
922
931
changerunmode (1 ,1 ,1 )
923
932
# threads
@@ -1043,26 +1052,26 @@ def export_vars():
1043
1052
args .unbantokens = unbantokens .get ()== 1
1044
1053
gpuchoiceidx = 0
1045
1054
if gpu_choice_var .get ()!= "All" :
1046
- if runopts_var .get () == runopts [ 1 ] : #if CLBlast selected
1055
+ if runopts_var .get () == "Use CLBlast" : #if CLBlast selected
1047
1056
if (gpu_choice_var .get ()) in CLdevices :
1048
1057
gpuchoiceidx = CLdevices .index ((gpu_choice_var .get ()))
1049
- elif runopts_var .get () == runopts [ 2 ] :
1058
+ elif runopts_var .get () == "Use CuBLAS/hipBLAS" :
1050
1059
if (gpu_choice_var .get ()) in CUdevices :
1051
1060
gpuchoiceidx = CUdevices .index ((gpu_choice_var .get ()))
1052
- if runopts_var .get () == runopts [ 1 ] :
1061
+ if runopts_var .get () == "Use CLBlast" :
1053
1062
args .useclblast = [[0 ,0 ], [1 ,0 ], [0 ,1 ]][gpuchoiceidx ]
1054
- if runopts_var .get () == runopts [ 2 ] :
1063
+ if runopts_var .get () == "Use CuBLAS/hipBLAS" :
1055
1064
if gpu_choice_var .get ()== "All" :
1056
1065
args .usecublas = ["lowvram" ] if lowvram_var .get () == 1 else ["normal" ]
1057
1066
else :
1058
1067
args .usecublas = ["lowvram" ,str (gpuchoiceidx )] if lowvram_var .get () == 1 else ["normal" ,str (gpuchoiceidx )]
1059
1068
if gpulayers_var .get ():
1060
1069
args .gpulayers = int (gpulayers_var .get ())
1061
- if runopts_var .get ()== runopts [ 3 ] :
1070
+ if runopts_var .get ()== "Use No BLAS" :
1062
1071
args .noblas = True
1063
- if runopts_var .get ()== runopts [ 4 ] :
1072
+ if runopts_var .get ()== "Use OpenBLAS (Old CPU, noavx2)" :
1064
1073
args .noavx2 = True
1065
- if runopts_var .get ()== runopts [ 5 ] :
1074
+ if runopts_var .get ()== "Failsafe Mode (Old CPU, noavx)" :
1066
1075
args .noavx2 = True
1067
1076
args .noblas = True
1068
1077
args .nommap = True
@@ -1101,38 +1110,42 @@ def import_vars(dict):
1101
1110
stream .set (1 if "stream" in dict and dict ["stream" ] else 0 )
1102
1111
smartcontext .set (1 if "smartcontext" in dict and dict ["smartcontext" ] else 0 )
1103
1112
unbantokens .set (1 if "unbantokens" in dict and dict ["unbantokens" ] else 0 )
1104
- runopts_var .set (runopts [0 ])
1105
1113
if "useclblast" in dict and dict ["useclblast" ]:
1106
- runopts_var .set (runopts [1 ])
1107
- gpu_choice_var .set (str (["0 0" , "1 0" , "0 1" ].index (str (dict ["useclblast" ][0 ]) + " " + str (dict ["useclblast" ][1 ])) + 1 ))
1114
+ if clblast_option is not None :
1115
+ runopts_var .set (clblast_option )
1116
+ gpu_choice_var .set (str (["0 0" , "1 0" , "0 1" ].index (str (dict ["useclblast" ][0 ]) + " " + str (dict ["useclblast" ][1 ])) + 1 ))
1108
1117
elif "usecublas" in dict and dict ["usecublas" ]:
1109
- runopts_var .set (runopts [2 ])
1110
- if len (dict ["usecublas" ])== 1 :
1111
- lowvram_var .set (1 if dict ["usecublas" ][0 ]== "lowvram" else 0 )
1112
- else :
1113
- lowvram_var .set (1 if "lowvram" in dict ["usecublas" ] else 0 )
1114
- gpu_choice_var .set ("1" )
1115
- for g in range (3 ):
1116
- if str (g ) in dict ["usecublas" ]:
1117
- gpu_choice_var .set (str (g + 1 ))
1118
- break
1118
+ if cublas_option is not None :
1119
+ runopts_var .set (cublas_option )
1120
+ if len (dict ["usecublas" ])== 1 :
1121
+ lowvram_var .set (1 if dict ["usecublas" ][0 ]== "lowvram" else 0 )
1122
+ else :
1123
+ lowvram_var .set (1 if "lowvram" in dict ["usecublas" ] else 0 )
1124
+ gpu_choice_var .set ("1" )
1125
+ for g in range (3 ):
1126
+ if str (g ) in dict ["usecublas" ]:
1127
+ gpu_choice_var .set (str (g + 1 ))
1128
+ break
1119
1129
if "gpulayers" in dict and dict ["gpulayers" ]:
1120
1130
gpulayers_var .set (dict ["gpulayers" ])
1121
1131
1122
1132
if "noavx2" in dict and "noblas" in dict and dict ["noblas" ] and dict ["noavx2" ]:
1123
- runopts_var .set (runopts [5 ])
1133
+ if failsafe_option is not None :
1134
+ runopts_var .set (failsafe_option )
1124
1135
elif "noavx2" in dict and dict ["noavx2" ]:
1125
- runopts_var .set (runopts [4 ])
1136
+ if openblas_noavx2_option is not None :
1137
+ runopts_var .set (openblas_noavx2_option )
1126
1138
elif "noblas" in dict and dict ["noblas" ]:
1127
- runopts_var .set (runopts [3 ])
1139
+ if default_option is not None :
1140
+ runopts_var .set (default_option )
1141
+ elif openblas_option is not None :
1142
+ runopts_var .set (openblas_option )
1128
1143
if "blasthreads" in dict and dict ["blasthreads" ]:
1129
1144
blas_threads_var .set (str (dict ["blasthreads" ]))
1130
1145
else :
1131
1146
blas_threads_var .set ("" )
1132
-
1133
1147
if "contextsize" in dict and dict ["contextsize" ]:
1134
1148
context_var .set (contextsize_text .index (str (dict ["contextsize" ])))
1135
-
1136
1149
if "ropeconfig" in dict and dict ["ropeconfig" ] and len (dict ["ropeconfig" ])> 1 :
1137
1150
if dict ["ropeconfig" ][0 ]> 0 :
1138
1151
customrope_var .set (1 )
@@ -1223,13 +1236,20 @@ def load_config():
1223
1236
time .sleep (2 )
1224
1237
sys .exit (2 )
1225
1238
1226
- def show_gui_warning ():
1239
+ def show_gui_warning (issue = None ):
1227
1240
from tkinter import messagebox
1228
1241
import tkinter as tk
1229
1242
root = tk .Tk ()
1230
1243
root .attributes ("-alpha" , 0 )
1231
- messagebox .showerror (title = "New GUI failed, using Old GUI" , message = "The new GUI failed to load.\n \n To use new GUI, please install the customtkinter python module." )
1232
- root .destroy ()
1244
+ if issue == "No Backend Available" :
1245
+ messagebox .showerror (title = "No Backends Available!" , message = "KoboldCPP couldn't locate any backends to use.\n \n To use the program, please run the 'make' command from the directory." )
1246
+ root .destroy ()
1247
+ print ("No Backend Available (i.e Default, OpenBLAS, CLBlast, CuBLAS). To use the program, please run the 'make' command from the directory." )
1248
+ time .sleep (2 )
1249
+ sys .exit (2 )
1250
+ else :
1251
+ messagebox .showerror (title = "New GUI failed, using Old GUI" , message = "The new GUI failed to load.\n \n To use new GUI, please install the customtkinter python module." )
1252
+ root .destroy ()
1233
1253
1234
1254
def show_old_gui ():
1235
1255
import tkinter as tk
0 commit comments