vLLM on a GPU VPS: Serving Open Models Through an OpenAI-Compatible Server
When a good local model serves one request slowly
An open model run through a single-response setup feels fine for personal use, but once several apps or users call it at once, the queue grows and latency balloons. Every request waits its full turn, even though the GPU could actually process many requests together if scheduling were designed for it. This is where the difference between "the model runs" and "the model serves" becomes real.
vLLM is an inference server designed for the serving side. With continuous batching and efficient KV cache memory management, it serves many concurrent requests at far higher throughput than a one-request-at-a-time server. Run through Docker on a GPU VPS, it presents any open model through an OpenAI-compatible endpoint on port 8000 — so apps already speaking OpenAI format need no changes.
This guide walks through installing vLLM on a GPU VPS, from the first container to a light concurrency test and endpoint security.
Prerequisites
Prepare a VPS with an NVIDIA GPU, host drivers, and the NVIDIA Container Toolkit installed and proven working — test with docker run --rm --gpus all nvidia/cuda:12.4.0-base-ubuntu22.04 nvidia-smi and confirm the GPU table appears. Also check Docker with:
docker --version docker compose version
Pick a model that fits your VRAM: an 8B model at full precision needs well over ten GB of VRAM, while 0.6B–3B models fit small cards and suit a first trial. For gated models on Hugging Face, prepare an HF_TOKEN — this guide's example uses an open model so no token is required.
Step 1: Run vLLM through Docker
Pull and run the official vllm/vllm-openai image with GPU access, a Hugging Face cache volume, and port 8000. The --ipc=host flag matters for multi-GPU setups and does no harm on a single GPU:
docker run -d --name vllm \ --runtime nvidia --gpus all \ -v ~/.cache/huggingface:/root/.cache/huggingface \ -p 127.0.0.1:8000:8000 \ --ipc=host \ vllm/vllm-openai:latest \ --model Qwen/Qwen3-8B
For a gated model, add --env "HF_TOKEN=hf_replace-with-your-token" before the image name. Expected result at this stage is not a server answering immediately, but a container downloading the model and loading it onto the GPU — this takes several minutes for an 8B model, depending on network and disk speed.
Watch the logs to learn when the server is ready:
docker logs -f vllm
The readiness signal to look for is a line saying the Uvicorn server runs on http://0.0.0.0:8000 and application startup is complete. If the logs stop on a memory error, the model is too large for your VRAM — drop to a smaller model or add the flags in step 4.
Which Docker image for CUDA 12.4?
The question comes up in exactly this form: which vLLM Docker image is best for inference on CUDA 12.4? The short answer: there is no CUDA 12.4-specific image tag. There is one official vLLM image, vllm/vllm-openai, and the CUDA version is not chosen through the tag — the CUDA runtime is bundled inside the image. What decides whether that image runs on your server is the NVIDIA driver on the host, not the CUDA number you type.
Three practical rules:
- Pin a version tag, not
latest.vllm/vllm-openai:latestmoves with every release, and server behavior can change without you noticing. Use a version tag such asvllm/vllm-openai:v0.11.0(swap in the version you have actually tested) and write that tag down in your deployment notes. The start command from Step 1 stays the same; only the image name changes. - Check the host driver before blaming the image. Run
nvidia-smion the host and look at the driver version. As long as the driver is new enough for the CUDA bundled in the image, the server runs — the image ships its own CUDA compatibility libraries to bridge the driver gap. The driver and toolkit setup itself is covered in Quick Trick: NVIDIA Container Toolkit + Docker GPU on a VPS. - If the host driver lags behind, turn on compatibility mode. Add
--env "VLLM_ENABLE_CUDA_COMPATIBILITY=1"to thedocker runcommand. That variable tells vLLM to use the CUDA compatibility libraries already in the image, so an older driver can still run a newer image. It is a way out for a server whose driver cannot be updated yet — not a substitute for updating the driver.
To confirm which CUDA the image you pulled actually uses, run:
docker run --rm --gpus all vllm/vllm-openai:v0.11.0 \
python3 -c "import torch; print(torch.version.cuda)"
The number printed is the CUDA that PyTorch uses inside the image — not the number from nvidia-smi on the host, which shows what the driver supports. If that number is newer than what your driver supports, that is when to use VLLM_ENABLE_CUDA_COMPATIBILITY=1 or update the driver.
One more note: the -ubuntu2404 tags are no longer published by the vLLM project — don't follow older tutorials that still write vllm/vllm-openai:latest-ubuntu2404. Use latest for experiments and a version tag for a server that has to stay stable.
Step 2: Check the model list and send a chat request
Once the server is ready, check the model list endpoint:
curl http://localhost:8000/v1/models
Expected result: a JSON response listing the model you started. Then send a chat request exactly as you would to the OpenAI API:
curl http://localhost:8000/v1/chat/completions \
-H "Content-Type: application/json" \
-d '{
"model": "Qwen/Qwen3-8B",
"messages": [{"role": "user", "content": "Explain Docker in one sentence."}]
}'Expected result: a JSON response with a choices array containing the answer. Note that the model name in the request must match the name used at start, unless you set --served-model-name — and setting a short served name is good practice, because that name is what your apps will write.
Step 3: Use a short served name and an API key
Recreate the container with a served name and an API key, so apps use a stable name and the endpoint is not open without authentication:
docker stop vllm && docker rm vllm docker run -d --name vllm \ --runtime nvidia --gpus all \ -v ~/.cache/huggingface:/root/.cache/huggingface \ -p 127.0.0.1:8000:8000 \ --ipc=host \ vllm/vllm-openai:latest \ --model Qwen/Qwen3-8B \ --served-model-name qwen3-8b \ --api-key token-replace-with-a-random-value
Test with the new name and key header:
curl http://localhost:8000/v1/chat/completions \
-H "Authorization: Bearer token-replace-with-a-random-value" \
-H "Content-Type: application/json" \
-d '{
"model": "qwen3-8b",
"messages": [{"role": "user", "content": "Reply with OK."}],
"max_tokens": 8
}'Expected result: a short, correct response. From this point, your apps use base_url http://localhost:8000/v1, model qwen3-8b, and the key above — the same pattern as any other OpenAI-compatible app.
Step 4: Tune memory use and context length
Two flags decide whether the server fits and stays stable on your GPU. --gpu-memory-utilization sets the fraction of VRAM vLLM may use, and --max-model-len caps context length so the KV cache does not overflow:
docker run -d --name vllm \ --runtime nvidia --gpus all \ -v ~/.cache/huggingface:/root/.cache/huggingface \ -p 127.0.0.1:8000:8000 \ --ipc=host \ vllm/vllm-openai:latest \ --model Qwen/Qwen3-8B \ --served-model-name qwen3-8b \ --gpu-memory-utilization 0.85 \ --max-model-len 8192 \ --api-key token-replace-with-a-random-value
The practical rule: start from the values above, and only raise --max-model-len if your app genuinely needs long context — longer context burns KV cache faster and reduces how many concurrent requests can be served. If the server fails to start with a memory error, lower --gpu-memory-utilization or --max-model-len, or move to a smaller model, in that order.
Step 5: Test several concurrent requests
vLLM's advantage only shows when many requests arrive together. Send five requests at once from the terminal and watch the total time:
for i in 1 2 3 4 5; do
curl -s http://localhost:8000/v1/chat/completions \
-H "Authorization: Bearer token-replace-with-a-random-value" \
-H "Content-Type: application/json" \
-d '{"model": "qwen3-8b", "messages": [{"role": "user", "content": "Name one number."}], "max_tokens": 8}' &
done
waitExpected result: all five responses return in far less time than five times one sequential request. If total time approaches five times a single request, check whether requests really ran concurrently or queued because of large max_tokens and context — and check GPU utilization with nvidia-smi during the test.
Step 6: Secure and maintain the server
Port 8000 binds to 127.0.0.1 in the examples above, so outside access must go through a TLS reverse proxy with extra authentication where needed — do not open this port raw to the internet, because the vLLM API key is the only barrier between the internet and your GPU. Save your exact start command, for example as a Compose file, so the server can be rebuilt with identical flags.
To update, stop the container, pull the new image, and restart with the same flags:
docker stop vllm && docker rm vllm docker pull vllm/vllm-openai:latest
Then rerun the full start command from step 4. Since model weights live in the Hugging Face cache volume, updates do not re-download the same model.
vLLM versus single-request servers and cloud APIs
| Aspect | Single-request server | vLLM on a GPU VPS | Cloud API |
|---|---|---|---|
| Many concurrent requests | Full queueing | Continuous batching | Yes, on the provider side |
| OpenAI-compatible endpoint | Depends on server | Yes, port 8000 | Native |
| Cost per call | Zero once hardware exists | Zero once hardware exists | Ongoing |
| GPU and VRAM management | Simple | Needs flag tuning | None needed |
| Best for | Personal use | Multi-user apps on your own server | Scale without managing GPUs |
That last row is the deciding factor. vLLM is the choice when your model is already good but its user queue starts to hurt — it turns a model that runs into a service that can be relied on.
Common mistakes and how to fix them
| Symptom | Most likely cause | Fix |
|---|---|---|
| Memory error at start | Model too large for VRAM | Lower gpu-memory-utilization, max-model-len, or model size |
| could not select device driver [[gpu]] | NVIDIA Toolkit not installed | Install the NVIDIA Container Toolkit, test a CUDA container |
| Model not found | Wrong model name, or gated access | Check the name on Hugging Face, add HF_TOKEN if needed |
| Requests rejected without a key | api-key active but header missing | Include the Authorization Bearer header on every request |
| Server slow despite idle GPU | Sequential requests, not concurrent | Test in parallel, check max_tokens and context |
| Container starts but never answers | Model still loading | Wait for the Uvicorn ready log, do not test too early |
| Port 8000 open to the internet | Port published on all interfaces | Bind to 127.0.0.1, add a TLS reverse proxy |
| Update changes behavior | latest tag moved | Record the working image tag, pin that tag |
The recurring pattern: most vLLM problems are not about the model, but about insufficient VRAM, a GPU not passed into the container, and tests run before the server finished loading the model.
Final checklist
- The NVIDIA Container Toolkit is proven working through a CUDA test container.
- The
vllmcontainer runs and logs report the server ready on port 8000. - The
/v1/modelsendpoint lists the running model. - A chat request with
--served-model-nameand an API key returns an answer. --gpu-memory-utilizationand--max-model-lenare tuned to VRAM.- A parallel test shows better throughput than sequential requests.
- The port binds only to
127.0.0.1until a TLS reverse proxy is ready.
Which open model would you serve with vLLM first, and how many concurrent requests do you want to handle? Share it in the comments, so other readers can compare their GPU setups with yours.
Read also: Quick Trick: NVIDIA Container Toolkit for Docker GPU and "VPS Pertama: Setup Ubuntu dan Hardening SSH dari Nol" for the server basics this guide builds on.


Diskusi
Ada pertanyaan atau pengalaman yang ingin dibagikan?
Komentar ditinjau sebelum ditampilkan. Mari berdiskusi dengan sopan dan sesuai topik.
Tulis komentar