~ruther/guix-local

24fad804f3dbdd9e5a653e85bc26e9b834a8cfdf — Danny Milosavljevic 1 year, 2 months ago aba3e48a
gnu: llama-cpp: Make the runtime check safer.

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

Change-Id: If72148fb3e8bf500d35c0987126a788ec410cdbd
1 files changed, 12 insertions(+), 13 deletions(-)

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