diff --git a/ggml/src/ggml-vulkan/ggml-vulkan.cpp b/ggml/src/ggml-vulkan/ggml-vulkan.cpp index f996674f4..1496dd47a 100644 --- a/ggml/src/ggml-vulkan/ggml-vulkan.cpp +++ b/ggml/src/ggml-vulkan/ggml-vulkan.cpp @@ -15265,7 +15265,10 @@ void ggml_backend_vk_get_device_memory(int device, size_t * free, size_t * total *total += heap.size; if (membudget_supported && i < budgetprops.heapUsage.size()) { - *free += budgetprops.heapBudget[i] - budgetprops.heapUsage[i]; + // Driver may report heapBudget > heap.size so we add a safeguard here + // See https://github.com/ggml-org/llama.cpp/issues/29277 + const vk::DeviceSize budget = std::min(budgetprops.heapBudget[i], heap.size); + *free += budget > budgetprops.heapUsage[i] ? budget - budgetprops.heapUsage[i] : 0; } else { *free += heap.size; }