fix(llm): try all available GPU types before falling back to CPU#237
Open
fix(llm): try all available GPU types before falling back to CPU#237
Conversation
The GPU initialization used `.find()` to pick only the first available GPU type (typically CUDA), and on failure fell directly to CPU — skipping Vulkan and Metal entirely. On Linux systems with Vulkan but no CUDA toolkit, this meant queries always ran on CPU despite a working GPU. Changed to `.filter()` + loop to try each available GPU in priority order (CUDA > Metal > Vulkan) before falling back to CPU. Fixes tobi#213 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
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.
Summary
.find()to pick only the first available GPU type (typically CUDA), and on failure fell directly to CPU — skipping Vulkan and Metal entirely.filter()+ loop to try each available GPU in priority order (CUDA → Metal → Vulkan → CPU)Problem
On Linux systems where
getLlamaGpuTypes()returns bothcudaandvulkan, the current code pickscudavia.find(). When CUDA initialization fails (no toolkit installed), thecatchblock falls straight togpu: false(CPU), never attempting Vulkan.This affects any system with Vulkan GPU support but no CUDA toolkit — e.g., AMD GPUs with
vulkan-radeon.Fix
Replace
.find()(first match) with.filter()+forloop (try all in order):Testing
Tested on Linux (Arch, kernel 6.19.3) with AMD Radeon 890M (RADV GFX1150, 47GB shared VRAM):
Fixes #213