mirror of
https://github.com/LostRuins/koboldcpp.git
synced 2026-09-18 16:55:14 +02:00
fix device enumeration issues
This commit is contained in:
+19
-13
@@ -1020,12 +1020,10 @@ def init_library():
|
|||||||
handle.set_environment_variable.restype = ctypes.c_int
|
handle.set_environment_variable.restype = ctypes.c_int
|
||||||
handle.set_environment_variable.argtypes = [ctypes.c_char_p, ctypes.c_char_p]
|
handle.set_environment_variable.argtypes = [ctypes.c_char_p, ctypes.c_char_p]
|
||||||
|
|
||||||
def set_backend_props(inputs):
|
def prepare_backend_visibility():
|
||||||
# we must force an explicit tensor split
|
kcpp_main_gpu = -1
|
||||||
# otherwise the default will divide equally and multigpu crap will slow it down badly
|
|
||||||
inputs.kcpp_main_gpu = -1
|
|
||||||
if(args.maingpu is not None and args.maingpu>=0):
|
if(args.maingpu is not None and args.maingpu>=0):
|
||||||
inputs.kcpp_main_gpu = args.maingpu
|
kcpp_main_gpu = args.maingpu
|
||||||
|
|
||||||
if args.usecuda:
|
if args.usecuda:
|
||||||
os.environ["CUDA_DEVICE_ORDER"] = "PCI_BUS_ID"
|
os.environ["CUDA_DEVICE_ORDER"] = "PCI_BUS_ID"
|
||||||
@@ -1033,35 +1031,42 @@ def set_backend_props(inputs):
|
|||||||
if (args.usecuda and "0" in args.usecuda):
|
if (args.usecuda and "0" in args.usecuda):
|
||||||
os.environ["CUDA_VISIBLE_DEVICES"] = "0"
|
os.environ["CUDA_VISIBLE_DEVICES"] = "0"
|
||||||
os.environ["HIP_VISIBLE_DEVICES"] = "0"
|
os.environ["HIP_VISIBLE_DEVICES"] = "0"
|
||||||
inputs.kcpp_main_gpu = 0
|
kcpp_main_gpu = 0
|
||||||
elif (args.usecuda and "1" in args.usecuda):
|
elif (args.usecuda and "1" in args.usecuda):
|
||||||
os.environ["CUDA_VISIBLE_DEVICES"] = "1"
|
os.environ["CUDA_VISIBLE_DEVICES"] = "1"
|
||||||
os.environ["HIP_VISIBLE_DEVICES"] = "1"
|
os.environ["HIP_VISIBLE_DEVICES"] = "1"
|
||||||
inputs.kcpp_main_gpu = 0
|
kcpp_main_gpu = 0
|
||||||
elif (args.usecuda and "2" in args.usecuda):
|
elif (args.usecuda and "2" in args.usecuda):
|
||||||
os.environ["CUDA_VISIBLE_DEVICES"] = "2"
|
os.environ["CUDA_VISIBLE_DEVICES"] = "2"
|
||||||
os.environ["HIP_VISIBLE_DEVICES"] = "2"
|
os.environ["HIP_VISIBLE_DEVICES"] = "2"
|
||||||
inputs.kcpp_main_gpu = 0
|
kcpp_main_gpu = 0
|
||||||
elif (args.usecuda and "3" in args.usecuda):
|
elif (args.usecuda and "3" in args.usecuda):
|
||||||
os.environ["CUDA_VISIBLE_DEVICES"] = "3"
|
os.environ["CUDA_VISIBLE_DEVICES"] = "3"
|
||||||
os.environ["HIP_VISIBLE_DEVICES"] = "3"
|
os.environ["HIP_VISIBLE_DEVICES"] = "3"
|
||||||
inputs.kcpp_main_gpu = 0
|
kcpp_main_gpu = 0
|
||||||
else:
|
else:
|
||||||
if(args.maingpu is None or args.maingpu<0):
|
if(args.maingpu is None or args.maingpu<0):
|
||||||
if (args.usecuda and "0" in args.usecuda):
|
if (args.usecuda and "0" in args.usecuda):
|
||||||
inputs.kcpp_main_gpu = 0
|
kcpp_main_gpu = 0
|
||||||
elif (args.usecuda and "1" in args.usecuda):
|
elif (args.usecuda and "1" in args.usecuda):
|
||||||
inputs.kcpp_main_gpu = 1
|
kcpp_main_gpu = 1
|
||||||
elif (args.usecuda and "2" in args.usecuda):
|
elif (args.usecuda and "2" in args.usecuda):
|
||||||
inputs.kcpp_main_gpu = 2
|
kcpp_main_gpu = 2
|
||||||
elif (args.usecuda and "3" in args.usecuda):
|
elif (args.usecuda and "3" in args.usecuda):
|
||||||
inputs.kcpp_main_gpu = 3
|
kcpp_main_gpu = 3
|
||||||
|
|
||||||
if "GGML_VK_VISIBLE_DEVICES" not in os.environ:
|
if "GGML_VK_VISIBLE_DEVICES" not in os.environ:
|
||||||
if args.usevulkan: # is an empty array if using vulkan without defined gpu
|
if args.usevulkan: # is an empty array if using vulkan without defined gpu
|
||||||
vulkangpus = ','.join([str(g) for g in args.usevulkan])
|
vulkangpus = ','.join([str(g) for g in args.usevulkan])
|
||||||
handle.set_environment_variable("GGML_VK_VISIBLE_DEVICES".encode("UTF-8"),vulkangpus.encode("UTF-8"))
|
handle.set_environment_variable("GGML_VK_VISIBLE_DEVICES".encode("UTF-8"),vulkangpus.encode("UTF-8"))
|
||||||
|
|
||||||
|
return kcpp_main_gpu
|
||||||
|
|
||||||
|
def set_backend_props(inputs):
|
||||||
|
# we must force an explicit tensor split
|
||||||
|
# otherwise the default will divide equally and multigpu crap will slow it down badly
|
||||||
|
inputs.kcpp_main_gpu = prepare_backend_visibility()
|
||||||
|
|
||||||
# set universal flags
|
# set universal flags
|
||||||
inputs.devices_override = (args.device if args.device else "").encode("UTF-8")
|
inputs.devices_override = (args.device if args.device else "").encode("UTF-8")
|
||||||
inputs.quiet = args.quiet
|
inputs.quiet = args.quiet
|
||||||
@@ -11965,6 +11970,7 @@ def kcpp_main_process(launch_args, g_memory=None, gui_launcher=False):
|
|||||||
friendlysdmodelname = os.path.basename(imgmodel)
|
friendlysdmodelname = os.path.basename(imgmodel)
|
||||||
friendlysdmodelname = os.path.splitext(friendlysdmodelname)[0]
|
friendlysdmodelname = os.path.splitext(friendlysdmodelname)[0]
|
||||||
friendlysdmodelname = sanitize_string(friendlysdmodelname)
|
friendlysdmodelname = sanitize_string(friendlysdmodelname)
|
||||||
|
prepare_backend_visibility()
|
||||||
cached_sd_info = sd_get_info()
|
cached_sd_info = sd_get_info()
|
||||||
loadok = sd_load_model(imgmodel,imgvae,imgt5xxl,imgclip1,imgclip2,imgphotomaker,imgupscaler,imgaudiovae)
|
loadok = sd_load_model(imgmodel,imgvae,imgt5xxl,imgclip1,imgclip2,imgphotomaker,imgupscaler,imgaudiovae)
|
||||||
print("Load Image Model OK: " + str(loadok))
|
print("Load Image Model OK: " + str(loadok))
|
||||||
|
|||||||
Reference in New Issue
Block a user