Skip to content

feat: enable GPU passthrough for ollama container - #49

Open
n0nuser wants to merge 1 commit into
mainfrom
feat/ollama-gpu-passthrough
Open

feat: enable GPU passthrough for ollama container#49
n0nuser wants to merge 1 commit into
mainfrom
feat/ollama-gpu-passthrough

Conversation

@n0nuser

@n0nuser n0nuser commented Jul 9, 2026

Copy link
Copy Markdown
Owner

Summary

  • Adds deploy.resources.reservations.devices GPU reservation to the ollama service in docker-compose.yml, requesting the nvidia driver/GPU capability.
  • Requires nvidia-container-toolkit on 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-smi shows the GPU inside the container.
  • /api/ps reports non-zero size_vram for the loaded model.
  • Warm inference call: 74 tokens in 577ms (~128 tok/s) vs. CPU-bound before.

Test plan

  • docker compose up -d ollama recreates cleanly with the new reservation
  • GPU visible inside container
  • Model loads into VRAM, inference measurably faster

https://claude.ai/code/session_01JUuyBTQaWsVcVygdHhT2iT

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
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