Skip to content

Commit

Permalink
Merge pull request #27 from one-lithe-rune/allow-sdk-dll-loading - Al…
Browse files Browse the repository at this point in the history
…low use of hip SDK (if installed) dlls on windows

* If the rocm/hip sdk is installed on windows, then include the sdk
as a potential location to load the hipBlas/rocBlas .dlls from. This
allows running koboldcpp.py directly with python after building
work on windows without having to build the .exe and run that or
copy .dlls around.
  • Loading branch information
one-lithe-rune authored and YellowRoseCx committed Oct 9, 2023
1 parent 5934e9f commit b01a449
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions koboldcpp.py
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,10 @@ def init_library():
os.add_dll_directory(dir_path)
os.add_dll_directory(abs_path)
os.add_dll_directory(os.getcwd())
if libname == lib_hipblas and "HIP_PATH" in os.environ:
os.add_dll_directory(os.path.join(os.environ["HIP_PATH"], "bin"))
if args.debugmode == 1:
print(f"HIP/ROCm SDK at {os.environ['HIP_PATH']} included in .DLL load path")
handle = ctypes.CDLL(os.path.join(dir_path, libname)) #, winmode=0)

handle.load_model.argtypes = [load_model_inputs]
Expand Down Expand Up @@ -973,7 +977,7 @@ def getfilename(var, text):
button = ctk.CTkButton(parent, 50, text="Browse", command= lambda a=var,b=searchtext:getfilename(a,b))
button.grid(row=row+1, column=1, stick="nw")
return

from subprocess import run, CalledProcessError
def get_device_names():
CUdevices = []
Expand Down Expand Up @@ -1297,7 +1301,7 @@ def export_vars():
if gpu_choice_var.get()!="All":
if runopts_var.get() == "Use CLBlast": #if CLBlast selected
if (gpu_choice_var.get()) in CLdevices:
gpuchoiceidx = CLdevices.index((gpu_choice_var.get()))
gpuchoiceidx = CLdevices.index((gpu_choice_var.get()))
elif runopts_var.get() == "Use CuBLAS" or runopts_var.get() == "Use hipBLAS (ROCm)":
if (gpu_choice_var.get()) in CUdevices:
gpuchoiceidx = CUdevices.index((gpu_choice_var.get()))
Expand Down Expand Up @@ -1430,7 +1434,7 @@ def import_vars(dict):
horde_workername_var.set(dict["hordeconfig"][4])
usehorde_var.set("1")


def save_config():
file_type = [("KoboldCpp Settings", "*.kcpps")]
filename = asksaveasfile(filetypes=file_type, defaultextension=file_type)
Expand Down Expand Up @@ -1581,7 +1585,7 @@ def onDropdownChange(event):
#load all the vars
args.threads = int(threads_var.get())
args.gpulayers = int(gpu_layers_var.get())

args.stream = (stream.get()==1)
args.smartcontext = (smartcontext.get()==1)
args.launch = (launchbrowser.get()==1)
Expand Down

0 comments on commit b01a449

Please sign in to comment.