gnu: llama-cpp: Make the runtime check safer.

* gnu/packages/patches/llama-cpp-vulkan-optional.patch: Make the runtime check
safer.

Change-Id: If72148fb3e8bf500d35c0987126a788ec410cdbd
This commit is contained in:
Danny Milosavljevic 2025-01-29 22:33:57 +01:00
parent aba3e48ae1
commit 24fad804f3
No known key found for this signature in database
GPG key ID: E71A35542C30BAA5

View file

@ -1,24 +1,23 @@
Author: Danny Milosavljevic <dannym@friendly-machines.com> Author: Danny Milosavljevic <dannym@friendly-machines.com>
Date: 2025-01-29 Date: 2025-01-29
License: Expat License: Expat
Subject: Make Vulkan optional
diff -ru orig/llama.cpp/ggml/src/ggml-vulkan/ggml-vulkan.cpp llama.cpp/ggml/src/ggml-vulkan/ggml-vulkan.cpp --- orig/llama.cpp/ggml/src/ggml-vulkan/ggml-vulkan.cpp 2025-01-29 10:24:10.922476480 +0100
--- orig/llama.cpp/ggml/src/ggml-vulkan/ggml-vulkan.cpp 2025-01-29 06:24:10.922476480 +0100 +++ llama.cpp/ggml/src/ggml-vulkan/ggml-vulkan.cpp 2025-01-29 22:33:19.955087552 +0100
+++ llama.cpp/ggml/src/ggml-vulkan/ggml-vulkan.cpp 2025-01-29 06:26:45.973357439 +0100 @@ -8174,8 +8174,13 @@
@@ -7317,9 +7317,13 @@ /* .iface = */ ggml_backend_vk_reg_i,
} /* .context = */ nullptr,
};
static int ggml_vk_get_device_count() {
- ggml_vk_instance_init();
- -
- return vk_instance.device_indices.size(); - return &reg;
+ try { + try {
+ ggml_vk_instance_init(); + ggml_vk_instance_init();
+ return vk_instance.device_indices.size(); + return &reg;
+ } catch (const vk::SystemError& e) { + } catch (const vk::SystemError& e) {
+ std::cerr << "ggml_vulkan: Error: System error" << std::endl; + VK_LOG_DEBUG("ggml_vk_get_device_count() -> Error: System error: " << e.what());
+ return 0; + return nullptr;
+ } + }
} }
static void ggml_vk_get_device_description(int device, char * description, size_t description_size) { // Extension availability