Local inference with vLLM on NVIDIA
Last updated: 2026-11-24T13:10:14-03:00 (UTC-3)
vLLM serves models on NVIDIA GPUs from the image vllm/vllm-openai. This page covers the three ways to put it behind a local inference pool: replicas the gateway starts with Docker, replicas you start yourself and register, and replicas in Kubernetes. The numbers were measured with vLLM 0.27.1 and Qwen2.5-0.5B-Instruct (bf16) on an NVIDIA L4 and an A100 40GB, with replicas started by the docker run command of this page and routed by the gateway.
A vLLM pool with a GPU needs the flags local_inference, local_inference_gpu and local_inference_nvidia, plus local_inference_mig for MIG slices.
The rule: one replica per GPU or MIG slice
Section titled “The rule: one replica per GPU or MIG slice”One vLLM process batches every request it holds on one device. Give each replica a device of its own:
| Layout on one A100 | 6 streams | 32 streams | 224 streams |
|---|---|---|---|
| One replica, whole card | 2,084 tok/s | 7,969 | 11,870 |
| Two replicas sharing the card (no MIG) | 1,026 | 5,059 | 23,136 |
Two replicas on two 3g.20gb MIG slices |
1,929 | 8,150 | 24,653 |
Seven replicas on seven 1g.5gb MIG slices |
805 | 3,823 | 16,470 |
- Two replicas sharing a card without MIG take turns on it and halve the throughput until one process saturates. The gateway accepts that layout only with
gpu.share_device: true, warns about it and defaults its alias toordered. - With MIG the slices are isolated and
least_busyis right at every load. - The slice size sets the speed of one stream (430 tokens per second on the whole card, 371 on
3g.20gb, 143 on1g.5gb). Use the fewest, largest slices your concurrency needs.
The gateway reads the layout that exists. It does not switch a card to MIG mode or create slices:
sudo nvidia-smi -i 0 -mig 1 && sudo systemctl reboot # MIG mode needs a reboot or a GPU resetsudo nvidia-smi mig -cgi 3g.20gb,3g.20gb -C # two slicesnvidia-smi -L # the UUIDs: MIG-...Replicas the gateway starts with Docker
Section titled “Replicas the gateway starts with Docker”Put the model on the host (the gateway never downloads it), then:
features: local_inference: true local_inference_gpu: true local_inference_nvidia: true local_inference_mig: truelocal_inference: supervise: true runtimes: container: /usr/bin/docker nvidia_smi: /usr/bin/nvidia-smi model_dirs: [/opt/models] container_images: ["vllm/vllm-openai:v0.27.1"] # pin a digest in production pools: - id: qwen backend: vllm mode: supervise model: qwen05 alias: local-qwen weights: /opt/models/Qwen2.5-0.5B-Instruct image: "vllm/vllm-openai:v0.27.1" replicas: 2 context_tokens: 4096 port_base: 8001 gpu: {mode: nvidia} # devices discovered with nvidia-smi; or devices: [MIG-..., MIG-...] health: {ready_timeout: 10m}For each replica the gateway runs, after removing a container left under the same name:
docker run --rm --name gateway-local-qwen-r1 --ipc=host --gpus device=MIG-<uuid> \ -p 127.0.0.1:8001:8000 -v /opt/models/Qwen2.5-0.5B-Instruct:/models/Qwen2.5-0.5B-Instruct:ro \ -e HF_HUB_OFFLINE=1 vllm/vllm-openai:v0.27.1 \ --model /models/Qwen2.5-0.5B-Instruct --served-model-name qwen05 --host 0.0.0.0 --port 8000 \ --gpu-memory-utilization 0.85 --max-model-len 4096- The replica is bound to one device with
--gpus device=<UUID>: a container on a MIG slice sees that slice and nothing else. - The weights are mounted read-only and the server runs offline.
- The port is published on
127.0.0.1only. slotsbecomes--max-num-seqs. A stop isdocker stopwithstop_graceas its timeout.- The gateway needs to run
docker, so the user it runs as needs access to the Docker socket. That is a strong permission: grant it only on a host dedicated to inference.
With gpu.mode: off no --gpus and no memory fraction are passed; pick an image built for the CPU.
Memory headroom
Section titled “Memory headroom”--gpu-memory-utilization is a fraction of the device the replica sees, a whole card or one slice. Leave room: on a 1g.5gb slice, 0.85 left 137 MiB free and a restarted replica failed to start; 0.70 held. So the default of gpu.memory_fraction is:
| Device | Default |
|---|---|
| A whole GPU, or a MIG slice of 10 GB or more | 0.85 |
| A smaller MIG slice, or a slice named by UUID whose size the gateway did not read | 0.70 |
A device shared by n replicas (share_device) |
the value above divided by n |
A replica that cannot start shows its exit status and the last line it wrote on the Local inference screen, with the device it was bound to.
Replicas you start yourself
Section titled “Replicas you start yourself”Start the containers with the command above (or any other way) and register them:
local_inference: pools: - id: qwen backend: vllm model: qwen05 alias: local-qwen endpoints: - {url: "http://10.0.0.5:8001/v1", device: MIG-<uuid-1>} - {url: "http://10.0.0.5:8002/v1", device: MIG-<uuid-2>}The gateway health-checks /health and /v1/models on each endpoint, routes by load and stops routing to one that fails. Stop and Start on the screen take a registered replica out of and back into routing; restarting it is yours. If the servers ask for a key (--api-key), name the environment variable that holds it in api_key_env.
Kubernetes
Section titled “Kubernetes”In a cluster the gateway does not start Pods: run vLLM as a workload and register the replicas. A StatefulSet with a headless Service gives each replica a stable name; request one GPU or one MIG slice per Pod. A starting point, to adapt to your GPU operator’s resource names and your storage:
apiVersion: apps/v1kind: StatefulSetmetadata: {name: vllm}spec: serviceName: vllm replicas: 2 selector: {matchLabels: {app: vllm}} template: metadata: {labels: {app: vllm}} spec: enableServiceLinks: false # a Service named vllm would inject VLLM_PORT, which vLLM reads as its own setting containers: - name: vllm image: vllm/vllm-openai:v0.27.1 args: ["--model", "/models/Qwen2.5-0.5B-Instruct", "--served-model-name", "qwen05", "--gpu-memory-utilization", "0.70", "--max-model-len", "4096"] ports: [{containerPort: 8000}] resources: {limits: {nvidia.com/gpu: 1}} # with MIG and the mixed strategy: nvidia.com/mig-1g.5gb: 1 readinessProbe: {httpGet: {path: /health, port: 8000}} volumeMounts: [{name: models, mountPath: /models, readOnly: true}] volumes: [{name: models, persistentVolumeClaim: {claimName: models}}]local_inference: pools: - id: qwen backend: vllm model: qwen05 alias: local-qwen endpoints: - {url: "http://vllm-0.vllm:8000/v1"} - {url: "http://vllm-1.vllm:8000/v1"}Every gateway replica probes the endpoints on its own. Scaling the StatefulSet is yours; add the new endpoint to the pool.
What to expect
Section titled “What to expect”Through the gateway with least_busy, 160 output tokens per stream:
| Layout | Streams | First token (median) | Total tokens/s |
|---|---|---|---|
| One replica on an L4 | 6 | 45 ms | 1,116 |
| One replica on an L4 | 32 | 109 ms | 4,719 |
Two 3g.20gb slices of an A100 |
6 | under 45 ms | 1,929 |
Two 3g.20gb slices of an A100 |
32 | under 75 ms | 8,150 |
Two 3g.20gb slices of an A100 |
224 | under 450 ms | 24,653 |
The gateway added 3 to 15 ms to the first token and cost 1% to 6% of the throughput against a replica called directly. A replica killed under 32 streams caused no HTTP error for requests that had not started; streams already running on it were cut and reported as stream_interrupted.
Metrics
Section titled “Metrics”vLLM publishes vllm: Prometheus metrics at /metrics. With provider_metrics_scrape on, every replica of the pool is scraped with no further setting, and the Local inference screen shows vllm:num_requests_running and vllm:num_requests_waiting per replica. In MIG mode nvidia-smi reports no utilization per slice; use the DCGM exporter (DCGM_FI_PROF_GR_ENGINE_ACTIVE, DCGM_FI_DEV_FB_USED) for that.