Skip to content

fix: use getLlamaGpuTypes("supported") to detect actual GPU availability#243

Open
DanieleSalatti wants to merge 1 commit intotobi:mainfrom
DanieleSalatti:fix/gpu-detection-use-supported
Open

fix: use getLlamaGpuTypes("supported") to detect actual GPU availability#243
DanieleSalatti wants to merge 1 commit intotobi:mainfrom
DanieleSalatti:fix/gpu-detection-use-supported

Conversation

@DanieleSalatti
Copy link

@DanieleSalatti DanieleSalatti commented Feb 21, 2026

Problem

On Linux machines without NVIDIA GPUs, QMD attempts to compile llama.cpp with CUDA support on every invocation. This adds ~30 seconds of noisy CMake failures to every qmd command before falling back to CPU.

Root cause

getLlamaGpuTypes() called without an argument returns all GPU types valid for the platform — on Linux that's always ["cuda", "vulkan", false] regardless of installed hardware. QMD then tries getLlama({gpu: "cuda"}), which triggers a source build of llama.cpp with GGML_CUDA=1, fails because there's no CUDA toolkit, and falls back to CPU.

Fix

Pass "supported" to getLlamaGpuTypes(), which checks for actual driver/library presence before including a GPU type. This is the intended API per node-llama-cpp docs.

Also removes the now-unnecessary @ts-expect-error directive — "supported" is a properly typed argument, so the type suppression was masking the issue.

Testing

Verified on Intel NUC (i7-1165G7, no discrete GPU) running Arch Linux

Before: every QMD command triggers ~30s of CUDA CMake build spam

After: instant startup, correctly detects CPU-only and skips GPU entirely

tsc passes clean with zero errors

Without the "supported" argument, getLlamaGpuTypes() returns all GPU
types valid for the platform (e.g. "cuda" on any Linux box) rather than
only those with actual drivers and libraries installed. This causes QMD
to attempt a CUDA build from source on machines without NVIDIA hardware,
resulting in a slow CMake failure on every invocation before falling back
to CPU.
@DanieleSalatti
Copy link
Author

I failed at copy & pasting the draft, updating description

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant