Ollama + Docker Compose GPU Passthrough in Linux/WSL2: How to fix 'could not select device driver nvidia' and share VRAM cleanly across concurrent agent workers?
We package our local agent stack (FastAPI + Ollama + Redis) using Docker Compose for developers running RTX 4090 / 3090 GPUs on Ubuntu and Windows WSL2.
Two Blocking Issues
- On fresh Linux/WSL2 hosts,
docker compose upcrashes immediately with:textError response from daemon: could not select device driver "" with capabilities: [[gpu]] - Once GPU passthrough is enabled, when 4 sub-agents hit Ollama concurrently (
qwen2.5-coder:14b+nomic-embed-text), Ollama repeatedly evicts the 14B model to load the embedding model, dropping throughput to a crawl and spiking VRAM past 24GB!
What is the exact nvidia-ctk setup + docker-compose.yml environment configuration (OLLAMA_NUM_PARALLEL, OLLAMA_KV_CACHE_TYPE) to keep both models resident in VRAM simultaneously?