From 2c24d67e7b78e07390c247340f67300523033194 Mon Sep 17 00:00:00 2001 From: Adam Treat Date: Sat, 16 Sep 2023 12:17:29 -0400 Subject: [PATCH] Don't crash on available devices if we can't even create an instance. --- ggml-vulkan.cpp | 2 +- kompute/src/Manager.cpp | 9 ++++++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/ggml-vulkan.cpp b/ggml-vulkan.cpp index a008ed3fb..c64fde832 100644 --- a/ggml-vulkan.cpp +++ b/ggml-vulkan.cpp @@ -131,7 +131,7 @@ static std::string ggml_vk_getVendorName(uint32_t vendorID) { std::vector ggml_vk_available_devices(size_t memoryRequired) { std::vector results; - if (!komputeManager()->hasVulkan()) + if (!komputeManager()->hasVulkan() || !komputeManager()->hasInstance()) return results; std::vector physicalDevices = komputeManager()->listDevices(); diff --git a/kompute/src/Manager.cpp b/kompute/src/Manager.cpp index 2a02b7b10..2a3ad2cc9 100644 --- a/kompute/src/Manager.cpp +++ b/kompute/src/Manager.cpp @@ -245,8 +245,15 @@ Manager::createInstance() VULKAN_HPP_DEFAULT_DISPATCHER.init(vkGetInstanceProcAddr); this->mInstance = std::make_shared(); - vk::createInstance( + vk::Result r = vk::createInstance( &computeInstanceCreateInfo, nullptr, this->mInstance.get()); + if (r != vk::Result::eSuccess) { + KP_LOG_ERROR( + "Kompute Manager Error allocating vulkan instance", vk::to_string(r)); + this->mInstance = nullptr; + this->mFreeInstance = false; + return; + } VULKAN_HPP_DEFAULT_DISPATCHER.init(*this->mInstance);