Skip to content

Commit

Permalink
kompute : ignore exceptions in ggml_vk_available_devices
Browse files Browse the repository at this point in the history
Sometimes Vulkan is not available due to VK_ERROR_INITIALIZATION_FAILED
or VK_ERROR_DEVICE_LOST. Ingore the exception instead of crashing.

Fixes nomic-ai/gpt4all#1477
  • Loading branch information
cebtenzzre committed Dec 1, 2023
1 parent f8feb9d commit 29fb13c
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions ggml-vulkan.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -141,9 +141,15 @@ std::vector<ggml_vk_device> ggml_vk_available_devices(size_t memoryRequired) {
if (!komputeManager()->hasVulkan() || !komputeManager()->hasInstance())
return results;

std::vector<vk::PhysicalDevice> physicalDevices = komputeManager()->listDevices();
uint32_t deviceCount = physicalDevices.size();
std::vector<vk::PhysicalDevice> physicalDevices;
try {
physicalDevices = komputeManager()->listDevices();
} catch (vk::SystemError & err) {
std::cerr << __func__ << ": ignoring Vulkan exception: " << err.what() << "\n";
return results;
}

uint32_t deviceCount = physicalDevices.size();
if (deviceCount == 0)
return results;

Expand Down

0 comments on commit 29fb13c

Please sign in to comment.