BestLLMfor EN Your hardware. Your LLM. Your call.
APIOpen data Find my LLM
Guide · 2026-07-15

How to Run vLLM in Docker with NVIDIA CUDA — 10-Minute Setup

Last updated 2026-07-15

From a clean machine to a live, OpenAI-compatible inference server in under 10 minutes — GPU passthrough, model sizing, and tuning included.

By Mohamed Meguedmi · 8 min read

Key Takeaways

  • The official vllm/vllm-openai image plus the NVIDIA Container Toolkit gets an OpenAI-compatible inference server live in under 10 minutes on any Ampere-or-newer NVIDIA GPU.
  • --gpus all and --ipc=host are non-negotiable — omit either and the container fails on CUDA initialization or shared-memory errors.
  • A single 24 GB card (RTX 4090 / 3090) comfortably serves a 7B–14B model in FP8; 32B+ needs 48 GB or tensor parallelism across two GPUs.
  • Pin the image tag (e.g. v0.10.2). Never run :latest in production — vLLM ships breaking changes roughly monthly.
  • Mount ~/.cache/huggingface to persist weights and cut cold starts from minutes to seconds.

Running vLLM inside Docker is the fastest, most reproducible way to stand up a high-throughput LLM server. The container bundles the exact CUDA runtime, PyTorch build, and Python dependencies vLLM needs, so you sidestep the dependency conflicts that plague bare-metal installs. vLLM's throughput advantage comes from PagedAttention, which manages the KV cache like virtual memory — the reason a single consumer GPU can serve thousands of tokens per second. This guide takes you from a clean machine to a live endpoint, and every VRAM and throughput figure below can be cross-checked against the free BestLLMfor cost calculator.

Prerequisites — What You Need Before You Start

You do not need the CUDA Toolkit installed on the host. The Docker image ships its own CUDA 12.x runtime; the host only needs a compatible NVIDIA driver and the container toolkit for GPU passthrough.

ComponentMinimumRecommendedNotes
GPUNVIDIA Ampere (RTX 30xx)Ada / Hopper (RTX 40xx, L40S, H100)Compute capability 7.0+; FP8 needs 8.9 (Ada) or 9.0 (Hopper)
NVIDIA driver525.60.13555 or newerMust satisfy the image's CUDA 12.x runtime
Docker Engine19.0324.0+19.03 introduced the --gpus flag
NVIDIA Container ToolkitLatestLatestProvides GPU passthrough into containers
Host RAM16 GB32 GB+For download staging and KV overflow
Free disk30 GB100 GB+A 7B model is ≈ 15 GB in FP16, ≈ 8 GB in FP8

Verify your driver with nvidia-smi on the host. The driver version must be equal to or newer than the CUDA minor version baked into the image — current vLLM images track CUDA 12.x, which needs driver 525.60.13 or later.

Step-by-Step: vLLM in Docker with CUDA

Four commands stand between you and a running server. On a machine that already has Docker and the driver, the whole thing takes about 10 minutes minus model download time.

  1. Install the NVIDIA Container Toolkit (Ubuntu/Debian shown; follow NVIDIA's install guide for other distros):
    curl -fsSL https://nvidia.github.io/libnvidia-container/gpgkey | sudo gpg --dearmor -o /usr/share/keyrings/nvidia-container-toolkit-keyring.gpg
    sudo apt-get update && sudo apt-get install -y nvidia-container-toolkit
    sudo nvidia-ctk runtime configure --runtime=docker && sudo systemctl restart docker
  2. Confirm GPU passthrough works before touching vLLM. This should print your GPU table:
    docker run --rm --gpus all nvidia/cuda:12.4.1-base-ubuntu22.04 nvidia-smi
    If this fails, fix it now — vLLM cannot succeed until this does.
  3. Pull and launch vLLM. This single command pulls the image, exposes the OpenAI-compatible API on port 8000, and loads a model from HuggingFace:
    docker run --runtime nvidia --gpus all \
      -v ~/.cache/huggingface:/root/.cache/huggingface \
      --env "HUGGING_FACE_HUB_TOKEN=YOUR_HF_TOKEN" \
      -p 8000:8000 --ipc=host \
      vllm/vllm-openai:v0.10.2 \
      --model Qwen/Qwen2.5-7B-Instruct --quantization fp8 --max-model-len 8192
    The -v mount persists downloaded weights on the host so restarts are near-instant. The token is only required for gated models.
  4. Test the endpoint once the log prints Application startup complete:
    curl http://localhost:8000/v1/chat/completions \
      -H "Content-Type: application/json" \
      -d '{"model": "Qwen/Qwen2.5-7B-Instruct", "messages": [{"role": "user", "content": "Explain PagedAttention in one sentence."}]}'

Because the API mirrors OpenAI's, any existing OpenAI client works by pointing base_url at http://localhost:8000/v1. Model details and cards, such as Qwen2.5-7B-Instruct, live on HuggingFace.

Choosing the Right Model for Your VRAM

VRAM is the single hard constraint. Weights are only half the story — the KV cache grows with context length and concurrency. Budget roughly 20% headroom above the weight size for a 4K-token context, more if you serve many concurrent requests.

ModelQuantWeights VRAM+KV cache (4K ctx)Min GPU
Qwen2.5-7B-InstructFP16~15 GB~18 GBRTX 4090 24 GB
Qwen2.5-7B-InstructFP8~8 GB~11 GBRTX 4070 Ti 16 GB
Qwen2.5-14B-InstructFP8~15 GB~19 GBRTX 4090 24 GB
Qwen2.5-32B-InstructFP8~33 GB~40 GB2× 24 GB (TP=2) or L40S 48 GB
Llama-3.3-70B-InstructFP8~70 GB~80 GB2× H100 80 GB

Our verdict: for a single 24 GB card, a 14B model in FP8 is the sweet spot — near-7B latency with a meaningful quality bump. Push to 32B only when you have 48 GB or a second GPU. Browse the full model catalog to compare quality tiers before committing VRAM.

Tuning vLLM Flags for Throughput and Memory

The defaults are sane, but four flags do most of the work when you need more concurrency or you are fighting an out-of-memory error:

  • --gpu-memory-utilization (default 0.90) — the fraction of VRAM vLLM claims for weights plus KV cache. Drop to 0.80 if the GPU also drives a display.
  • --max-model-len — caps context length. Shorter context means a smaller KV cache and more concurrent sequences.
  • --tensor-parallel-size N — shards the model across N GPUs. Set it equal to your GPU count for models that overflow one card.
  • --quantization fp8 — roughly halves weight memory versus FP16 with negligible quality loss on Ada/Hopper hardware.
  • --max-num-seqs — the ceiling on concurrent sequences; raise it for batch workloads, lower it to protect tail latency.

Benchmarks — What to Expect

Numbers below are approximate, measured with short prompts and 256-token generations. Batched throughput assumes a saturated request queue; single-stream is one request at a time. Full methodology and reproducible runs live on the benchmarks hub.

GPUModelConfigBatched throughputSingle-stream
RTX 4090Qwen2.5-7BFP8~2,900 tok/s~95 tok/s
RTX 4090Qwen2.5-14BFP8~1,500 tok/s~55 tok/s
2× RTX 4090Qwen2.5-32BFP8, TP=2~1,100 tok/s~40 tok/s
H100 80 GBLlama-3.3-70BFP8~2,400 tok/s~48 tok/s

The takeaway: batching is where vLLM shines. A 4090 serving 7B FP8 delivers ~30× the throughput of a single stream, which is why one consumer card can back a small team's internal API. Want to script comparisons? Every figure on this site is queryable through the free BestLLMfor public API (CC BY 4.0) and our open-source MCP server, so you can pull VRAM and throughput data straight into your own tooling.

Troubleshooting Common CUDA and Docker Errors

Ninety percent of failures fall into five buckets. Match the error text to the fix:

ErrorCauseFix
could not select device driver "" with capabilities: [[gpu]]Container Toolkit not configuredRun nvidia-ctk runtime configure and restart Docker
Failed to infer device typeHost driver too old for the image CUDAUpgrade the host NVIDIA driver
Bus error (core dumped)Insufficient shared memoryAdd --ipc=host or --shm-size=8g
CUDA out of memoryWeights + KV cache exceed VRAMLower --gpu-memory-utilization or --max-model-len, or switch to FP8
401 Client Error on downloadGated model, missing tokenPass HUGGING_FACE_HUB_TOKEN via --env

The Verdict

vLLM in Docker is the right default for anyone running local inference in 2026: reproducible, GPU-native, and OpenAI-compatible out of the box. Pin your tag, mount the HuggingFace cache, and match the model to your VRAM. Here is how we would set it up by scenario:

ScenarioRecommended setupWhy
Solo dev, 24 GB cardvllm/vllm-openai:v0.10.2, 7B–14B FP8Best balance of speed and simplicity
Small team APIAbove + Docker Compose, pinned tag, HF cache volumeReproducible and fast to restart
70B-class modelMulti-GPU tensor parallelism or a single H100 80 GBVRAM is the hard limit
ProductionPinned tag + health checks + Prometheus metricsStability over the bleeding edge

For deeper dives into deployment patterns and model selection, browse the rest of our guides.

Frequently Asked Questions

Do I need the CUDA Toolkit installed on the host?

No. The vLLM image ships its own CUDA 12.x runtime. You only need a compatible NVIDIA driver plus the NVIDIA Container Toolkit for GPU passthrough.

Can I run vLLM without --gpus all?

Not on GPU. Without it the container cannot see the GPU and vLLM fails during CUDA initialization. The flag (or an equivalent --gpus 'device=0') is mandatory.

Docker or a pip install — which should I use?

Docker, for anything beyond quick experimentation. It pins the CUDA runtime, PyTorch, and dependency versions together, eliminating the version drift that breaks bare-metal installs after an OS update.

How do I run a model across two GPUs?

Add --tensor-parallel-size 2 to the run command and keep --gpus all. vLLM shards the model layers across both cards automatically.

Does this work on AMD GPUs?

Not with this image. AMD requires the separate ROCm build of vLLM. This guide covers the NVIDIA CUDA path only.

Is it really a 10-minute setup?

Yes, excluding model download time. On a machine that already has Docker and a current driver, installing the toolkit, verifying passthrough, and launching the server takes well under 10 minutes. The first model pull adds a few minutes depending on bandwidth.

Recommended hardware

For running local LLMs comfortably, an RTX 5070 Ti (16 GB VRAM) is the best value for money.

Amazon Check RTX 5070 Ti price →

As an Amazon Associate, BestLLMfor earns from qualifying purchases, at no extra cost to you. It does not influence our independent rankings.