improved remotelink cmd, fixed lib unload, updated class.py

This commit is contained in:
Concedo 2023-09-25 17:50:00 +08:00
parent fdadbd0fbb
commit 17ee719c56
3 changed files with 53 additions and 15 deletions

View file

@ -1,2 +1,18 @@
curl -L https://github.com/cloudflare/cloudflared/releases/latest/download/cloudflared-windows-amd64.exe -o cloudflared.exe : # This script will help setup a cloudflared tunnel for accessing KoboldCpp over the internet
cloudflared.exe tunnel --url localhost:5001 : # It should work out of the box on both linux and windows
: # ======
: # WINDOWS PORTION
:<<BATCH
@echo off
echo Starting Cloudflare Tunnel for Windows
curl -L https://github.com/cloudflare/cloudflared/releases/latest/download/cloudflared-windows-amd64.exe -o cloudflared.exe
cloudflared.exe tunnel --url localhost:5001
GOTO ENDING
BATCH
: # LINUX PORTION
echo 'Starting Cloudflare Tunnel for Linux'
curl -L https://github.com/cloudflare/cloudflared/releases/latest/download/cloudflared-linux-amd64 -o 'cloudflared-linux-amd64' #
chmod +x 'cloudflared-linux-amd64' #
./cloudflared-linux-amd64 tunnel --url http://localhost:5001 #
exit #
:ENDING

View file

@ -188,6 +188,18 @@ class model_backend(InferenceModel):
"extra_classes": "", "extra_classes": "",
'children': [{'text': 'False', 'value': False}, {'text': 'True', 'value': True}], 'children': [{'text': 'False', 'value': False}, {'text': 'True', 'value': True}],
}) })
requested_parameters.append({
"uitype": "text",
"unit": "text",
"label": "GPU ID",
"id": "kcpp_tensor_split_str",
"default": "1",
"check": {"value": "", 'check': "!="},
"tooltip": "Which GPU's do we use? For example:1 2",
"menu_path": "",
"refresh_model_inputs": False,
"extra_classes": ""
})
requested_parameters.append({ requested_parameters.append({
"uitype": "dropdown", "uitype": "dropdown",
"unit": "int", "unit": "int",
@ -202,18 +214,6 @@ class model_backend(InferenceModel):
"extra_classes": "", "extra_classes": "",
'children': [{'text': 'False', 'value': 0}, {'text': 'True', 'value': 1}], 'children': [{'text': 'False', 'value': 0}, {'text': 'True', 'value': 1}],
}) })
requested_parameters.append({
"uitype": "text",
"unit": "text",
"label": "Tensor Split",
"id": "kcpp_tensor_split_str",
"default": self.kcpp_tensor_split_str,
"check": {"value": "", 'check': "!="},
"tooltip": "Tensor Split, values are space separated",
"menu_path": "",
"refresh_model_inputs": False,
"extra_classes": ""
})
return requested_parameters return requested_parameters
def set_input_parameters(self, parameters): def set_input_parameters(self, parameters):
@ -232,6 +232,7 @@ class model_backend(InferenceModel):
self.kcpp_tensor_split = [] self.kcpp_tensor_split = []
for s in splits: for s in splits:
self.kcpp_tensor_split.append(int(s)) self.kcpp_tensor_split.append(int(s))
print(self.kcpp_tensor_split)
accel = parameters["kcpp_accelerator"] accel = parameters["kcpp_accelerator"]
if accel==0: if accel==0:

View file

@ -1680,8 +1680,9 @@ def unload_libs():
dll_close = None dll_close = None
if OS == "Windows": # pragma: Windows if OS == "Windows": # pragma: Windows
from ctypes import wintypes from ctypes import wintypes
ctypes.windll.kernel32.FreeLibrary.argtypes = [wintypes.HMODULE]
dll_close = ctypes.windll.kernel32.FreeLibrary dll_close = ctypes.windll.kernel32.FreeLibrary
dll_close.argtypes = [wintypes.HMODULE]
dll_close.restype = ctypes.c_int
elif OS == "Darwin": elif OS == "Darwin":
try: try:
try: # macOS 11 (Big Sur). Possibly also later macOS 10s. try: # macOS 11 (Big Sur). Possibly also later macOS 10s.
@ -1693,19 +1694,27 @@ def unload_libs():
# not even in PATH. # not even in PATH.
stdlib = ctypes.CDLL("/usr/lib/system/libsystem_c.dylib") stdlib = ctypes.CDLL("/usr/lib/system/libsystem_c.dylib")
dll_close = stdlib.dlclose dll_close = stdlib.dlclose
dll_close.argtypes = [ctypes.c_void_p]
dll_close.restype = ctypes.c_int
elif OS == "Linux": elif OS == "Linux":
try: try:
stdlib = ctypes.CDLL("") stdlib = ctypes.CDLL("")
except OSError: except OSError:
stdlib = ctypes.CDLL("libc.so") # Alpine Linux. stdlib = ctypes.CDLL("libc.so") # Alpine Linux.
dll_close = stdlib.dlclose dll_close = stdlib.dlclose
dll_close.argtypes = [ctypes.c_void_p]
dll_close.restype = ctypes.c_int
elif sys.platform == "msys": elif sys.platform == "msys":
# msys can also use `ctypes.CDLL("kernel32.dll").FreeLibrary()`. # msys can also use `ctypes.CDLL("kernel32.dll").FreeLibrary()`.
stdlib = ctypes.CDLL("msys-2.0.dll") stdlib = ctypes.CDLL("msys-2.0.dll")
dll_close = stdlib.dlclose dll_close = stdlib.dlclose
dll_close.argtypes = [ctypes.c_void_p]
dll_close.restype = ctypes.c_int
elif sys.platform == "cygwin": elif sys.platform == "cygwin":
stdlib = ctypes.CDLL("cygwin1.dll") stdlib = ctypes.CDLL("cygwin1.dll")
dll_close = stdlib.dlclose dll_close = stdlib.dlclose
dll_close.argtypes = [ctypes.c_void_p]
dll_close.restype = ctypes.c_int
elif OS == "FreeBSD": elif OS == "FreeBSD":
# FreeBSD uses `/usr/lib/libc.so.7` where `7` is another version number. # FreeBSD uses `/usr/lib/libc.so.7` where `7` is another version number.
# It is not in PATH but using its name instead of its path is somehow the # It is not in PATH but using its name instead of its path is somehow the
@ -1716,6 +1725,18 @@ def unload_libs():
if handle and dll_close: if handle and dll_close:
print("Unloading Libraries...") print("Unloading Libraries...")
dll_close(handle._handle) dll_close(handle._handle)
del handle.load_model
del handle.generate
del handle.new_token
del handle.get_stream_count
del handle.has_finished
del handle.get_last_eval_time
del handle.get_last_process_time
del handle.get_last_token_count
del handle.get_last_stop_reason
del handle.abort_generate
del handle.token_count
del handle.get_pending_output
del handle del handle
handle = None handle = None