diff --git a/expose.cpp b/expose.cpp index c58ad8fa8..7507f6341 100644 --- a/expose.cpp +++ b/expose.cpp @@ -402,4 +402,13 @@ extern "C" { return gpttype_clear_state_kv(true); } + + void set_environment_variable(const char * identifier, const char * value) + { + #ifdef _WIN32 + _putenv_s(identifier, value); + #else + setenv(identifier, value, 1); + #endif + } } diff --git a/koboldcpp.py b/koboldcpp.py index 17c8dc5e5..21e19f2a0 100644 --- a/koboldcpp.py +++ b/koboldcpp.py @@ -989,7 +989,8 @@ def set_backend_props(inputs): if "GGML_VK_VISIBLE_DEVICES" not in os.environ: if args.usevulkan: # is an empty array if using vulkan without defined gpu - os.environ["GGML_VK_VISIBLE_DEVICES"] = ','.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")) # set universal flags inputs.devices_override = (args.device if args.device else "").encode("UTF-8")