mirror of
https://github.com/LostRuins/koboldcpp.git
synced 2026-05-16 19:59:16 +00:00
refactor: handle GGML_VK_VISIBLE_DEVICES at the Python level (#2179)
All C++ handling code currently: - build a comma-separated list from the info_vulkan array - if GGML_VK_VISIBLE_DEVICES isn't set - set GGML_VK_VISIBLE_DEVICES to the list Once set, GGML_VK_VISIBLE_DEVICES affects the whole process. So this can be done in the same way at the Python level, before all loading functions. Caveat: load_model had the default `inputs.vulkan_info = "0"`, so the default GPU would be "0" only when loading a text model.
This commit is contained in:
parent
42ce63fd3b
commit
25fab4113e
8 changed files with 3 additions and 120 deletions
17
expose.cpp
17
expose.cpp
|
|
@ -23,8 +23,6 @@
|
|||
extern "C"
|
||||
{
|
||||
|
||||
std::string vulkandeviceenv;
|
||||
|
||||
//return val: 0=fail, 1=(original ggml, alpaca), 2=(ggmf), 3=(ggjt)
|
||||
static FileFormat file_format = FileFormat::BADFORMAT;
|
||||
static FileFormatExtraMeta file_format_meta;
|
||||
|
|
@ -38,21 +36,6 @@ extern "C"
|
|||
|
||||
file_format = check_file_format(model.c_str(),&file_format_meta);
|
||||
|
||||
std::string vulkan_info_raw = inputs.vulkan_info;
|
||||
std::string vulkan_info_str = "";
|
||||
for (size_t i = 0; i < vulkan_info_raw.length(); ++i) {
|
||||
vulkan_info_str += vulkan_info_raw[i];
|
||||
if (i < vulkan_info_raw.length() - 1) {
|
||||
vulkan_info_str += ",";
|
||||
}
|
||||
}
|
||||
const char* existingenv = getenv("GGML_VK_VISIBLE_DEVICES");
|
||||
if(!existingenv && vulkan_info_str!="")
|
||||
{
|
||||
vulkandeviceenv = "GGML_VK_VISIBLE_DEVICES="+vulkan_info_str;
|
||||
putenv((char*)vulkandeviceenv.c_str());
|
||||
}
|
||||
|
||||
executable_path = inputs.executable_path;
|
||||
|
||||
if(file_format==FileFormat::GPTJ_1 || file_format==FileFormat::GPTJ_2 || file_format==FileFormat::GPTJ_3 || file_format==FileFormat::GPTJ_4 || file_format==FileFormat::GPTJ_5)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue