Detect Vulkan via the loader before falling back to vulkaninfo - #1446
Merged
martindevans merged 1 commit intoOct 1, 2026
Merged
Conversation
SystemInfo.GetVulkanVersion relied solely on spawning `vulkaninfo --summary`. That tool ships with the Vulkan SDK / some driver bundles, not with every Vulkan-capable driver (e.g. Windows machines with only an Intel GPU), and the external process can be slow or time out (SciSharp#930). When it is missing the Vulkan backend is silently skipped and only the CPU backend is offered. Query the loader in-process with vkEnumerateInstanceVersion first (vulkan-1.dll on Windows, libvulkan.so.1 on Linux) and only fall back to vulkaninfo when the loader is absent or the call fails. Behaviour on machines without Vulkan is unchanged. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
martindevans
approved these changes
Oct 1, 2026
martindevans
left a comment
Member
There was a problem hiding this comment.
Thanks for putting this together, it looks good to me. I'll merge it once the tests complete.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
SystemInfo.GetVulkanVersion()detects Vulkan only by spawningvulkaninfo --summaryand parsing its output.vulkaninfois a developer tool that comes with the Vulkan SDK (and is bundled by some driver installers, e.g. NVIDIA), but it is not part of the Vulkan loader or of every driver. On a Windows machine with only an Intel GPU (tested on an Intel N100 box) the driver installs a fully workingvulkan-1.dllbut novulkaninfo.exe. LLamaSharp then concludes there is no Vulkan, skipsLLamaSharp.Backend.Vulkan, andggmlonly ever lists the CPU device. The user gets CPU inference with no error.Spawning an external process also has the latency / timeout problems already discussed in #884, #885 and #930.
Fix
Ask the loader directly first:
vkEnumerateInstanceVersion(Vulkan 1.1+) fromvulkan-1.dllon Windows orlibvulkan.so.1on Linux.major.minor.patch(same shape as the string parsed fromvulkaninfoon Windows).vulkaninfo --summarypath unchanged.VulkanVersionis only tested for!= nullbyNativeLibraryWithVulkan, so the string format change on Linux (previously4206847 (1.3.255)fromvulkaninfo) has no functional effect.Testing
LLama/LLamaSharp.csproj(netstandard2.0 + net8.0), no new warnings.1.4.350, matching the installed loader's file version.vulkaninfo) since 2026-09; Vulkan backend is now selected and the iGPU is listed.DllNotFoundExceptionis caught and the old path runs, so behaviour is unchanged.