fix: respect NODE_LLAMA_CPP_GPU and GGML_CUDA env vars for CPU-only mode#266
Open
fix: respect NODE_LLAMA_CPP_GPU and GGML_CUDA env vars for CPU-only mode#266
Conversation
When running on systems without a GPU, qmd would still try to use CUDA if the CUDA libraries were detected by getLlamaGpuTypes(). This caused unnecessary CUDA builds and high CPU usage. This fix checks for NODE_LLAMA_CPP_GPU=false or GGML_CUDA=OFF environment variables and forces CPU-only mode, skipping GPU detection entirely. Related: tobi#185
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
On systems without a physical GPU, qmd still attempts to use CUDA if the CUDA toolkit or libraries are installed. This happens because:
getLlamaGpuTypes()fromnode-llama-cppdetects CUDA libraries on the systemgetLlama({ gpu: "cuda", ... })to use CUDAEven when setting environment variables like:
NODE_LLAMA_CPP_GPU=falseGGML_CUDA=OFFNODE_LLAMA_CPP_CMAKE_OPTION_GGML_CUDA=OFF(related issue macOS Intel: unnecessary CUDA build attempt causes ~30s delay on every startup #185)qmd would ignore these variables and still try to use CUDA if detected.
Impact
NODE_LLAMA_CPP_GPU=falsehas no effectSolution
This PR modifies the
ensureLlama()function insrc/llm.tsto:getLlamaGpuTypes()NODE_LLAMA_CPP_GPU=falseorGGML_CUDA=OFFis set, skip GPU detection entirelygetLlama({ gpu: false, ... })Environment Variables Supported
NODE_LLAMA_CPP_GPU"false"GGML_CUDA"OFF"Usage
Users without GPUs can now reliably force CPU-only mode:
Testing
Tested on a system without GPU:
NODE_LLAMA_CPP_GPU=falseis set@node-llama-cpp/linux-x64Related
NODE_LLAMA_CPP_CMAKE_OPTION_GGML_CUDA=OFFbut this alone is insufficient because qmd explicitly requests CUDA mode regardless of cmake optionsNotes
node-llama-cppenvironment variables