diff --git a/ggml-vulkan.cpp b/ggml-vulkan.cpp index b03207c42..89c29346e 100644 --- a/ggml-vulkan.cpp +++ b/ggml-vulkan.cpp @@ -1415,8 +1415,15 @@ void ggml_vk_instance_init() { vk_instance.device_indices.push_back(tmp); } } else { - // Default to using all dedicated GPUs std::vector devices = vk_instance.instance.enumeratePhysicalDevices(); + + // Make sure at least one device exists + if (devices.empty()) { + std::cerr << "ggml_vulkan: Error: No devices found." << std::endl; + GGML_ASSERT(false); + } + + // Default to using all dedicated GPUs for (size_t i = 0; i < devices.size(); i++) { vk::PhysicalDeviceProperties props = devices[i].getProperties(); @@ -1424,6 +1431,11 @@ void ggml_vk_instance_init() { vk_instance.device_indices.push_back(i); } } + + // If no dedicated GPUs found, fall back to GPU 0 + if (vk_instance.device_indices.empty()) { + vk_instance.device_indices.push_back(0); + } } std::cerr << "ggml_vulkan: Found " << vk_instance.device_indices.size() << " Vulkan devices:" << std::endl;