feat: enable GPU passthrough for ollama container - #49
Open
n0nuser wants to merge 1 commit into
Open
Conversation
nvidia-container-toolkit wasn't installed on the WSL2 host, so Docker never requested GPU access even though the host driver (nvidia-smi) and WSL2's own CUDA shim worked fine. Ollama fell back to 100% CPU inference, turning a 23-item offline RAGAS eval into a 9+ minute (incomplete) run. Add the compose-level GPU reservation so `docker compose up` requests the GPU once the toolkit is present on the host. Verified: container sees the GPU (nvidia-smi), /api/ps reports non-zero size_vram, and a warm inference call dropped from CPU-bound to ~128 tok/s. Claude-Session: https://claude.ai/code/session_01JUuyBTQaWsVcVygdHhT2iT
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
deploy.resources.reservations.devicesGPU reservation to theollamaservice indocker-compose.yml, requesting the nvidia driver/GPU capability.nvidia-container-toolkiton the host (WSL2 in this case) — the compose change alone is a no-op without it, but is also harmless if the toolkit isn't present (Docker just won't have a GPU to grant).Why
Local RAGAS evals run inference against Ollama in Docker. Without GPU passthrough, Ollama silently fell back to 100% CPU, turning what should be a fast offline eval into 9+ minutes for 23 dataset items (never finished in one observed run). Host GPU (12GB card) was idle the whole time.
Verified
docker exec localrag-ollama-1 nvidia-smishows the GPU inside the container./api/psreports non-zerosize_vramfor the loaded model.Test plan
docker compose up -d ollamarecreates cleanly with the new reservationhttps://claude.ai/code/session_01JUuyBTQaWsVcVygdHhT2iT