vLLM Fix, Crash & Optimization Guide
vLLM crashing, out of GPU memory, or serving errors? Real OpenAI-compatible LLM inference fixes, throughput tuning and version notes.
vLLM Fix, Crash & Optimization Guide
vLLM is a high-throughput inference and serving engine for large language models, built around PagedAttention for efficient KV-cache memory use. It is used by engineers deploying open-weight models behind an OpenAI-compatible API.
Install / First Setup
vLLM is installed from PyPI into a Python environment with a compatible CUDA toolchain:
pip install vllm
Start the OpenAI-compatible server:
python -m vllm.entrypoints.openai.api_server --model meta-llama/Llama-3-8b --host 0.0.0.0 --port 8000
# newer releases also accept the shorthand:
vllm serve meta-llama/Llama-3-8b
A CUDA-capable GPU is required for normal use. CPU-only execution is experimental and limited.
Common Issues & Fixes
torch.cuda.OutOfMemoryError / model does not fit
Cause: The model weights plus the KV cache exceed GPU memory, often because max_model_len is too large.
Fix: Lower --max-model-len, reduce --gpu-memory-utilization (default 0.90) to leave headroom, or use tensor parallelism across multiple GPUs with --tensor-parallel-size N. Quantized weights (AWQ/GPTQ) also cut memory.
ValueError: max_model_len (N) is larger than the maximum ...
Cause: Requested context length exceeds the model's trained position limit.
Fix: Set --max-model-len to a value at or below the model's supported sequence length, e.g. --max-model-len 4096.
CUDA / torch version mismatch at import
Cause: The installed PyTorch CUDA build does not match the vLLM build.
Fix: Reinstall a matching PyTorch wheel for your CUDA version, then reinstall vLLM. Check python -c "import torch; print(torch.version.cuda)" and align it with vLLM's requirements.
Address already in use (port 8000)
Cause: Another process is bound to the port.
Fix: Change the port with --port 8001, or stop the conflicting service.
FlashAttention / build errors during pip install
Cause: Missing CUDA toolkit or a too-new/too-old compiler.
Fix: Install a CUDA toolkit matching your driver and a supported gcc/clang. If prebuilt wheels exist for your platform, prefer pip install vllm over building from source to avoid compilation.
Performance & Optimization
- Low-End (single 8–16 GB VRAM GPU): Use 7B-class models,
--quantization awqorgptq, set--gpu-memory-utilization 0.85, and keep--max-model-lenmodest (2048–4096). - Mid-Range (24 GB VRAM, e.g. RTX 4090): 13B–34B models fit; raise
--max-model-lento 8192 and leave--gpu-memory-utilizationnear default for headroom. - Workstation / multi-GPU: Use
--tensor-parallel-sizeequal to GPU count, enable continuous batching (default), and serve many concurrent requests. PagedAttention already minimizes KV fragmentation, so focus on--max-num-seqsand batch sizing for your latency targets. - Speculative decoding and quantization reduce cost but can change output quality; validate before production.
Version & Compatibility Notes
vLLM requires a CUDA GPU and a supported Python (3.8+ on most releases; consult the current docs). It tracks recent PyTorch and CUDA versions and changes rapidly. For the exact supported Python, CUDA, and model list, consult the official vLLM release notes and documentation.
FAQ
Q: Is vLLM OpenAI-compatible?
A: Yes. The API server exposes /v1/completions, /v1/chat/completions, and /v1/models compatible with OpenAI client libraries.
Q: How do I limit context length?
A: Pass --max-model-len to the server. Requests exceeding it are rejected.
Q: Can I run vLLM on CPU only? A: CPU execution exists but is experimental and slow; it is not recommended for production serving.
Q: How do I serve a quantized model?
A: Pass --quantization awq (or gptq) together with the quantized model path. The model files must match the quantization method.
Q: Does vLLM support AMD GPUs? A: ROCm builds exist for certain releases; support varies by version and GPU. Consult the official docs for current ROCm guidance.
Q: How do I set the served model name?
A: Use --served-model-name to control the identifier clients use in the model field.
Related Guides
- Ollama Fix & Optimization Guide
- LM Studio Fix & Optimization Guide
- Hugging Face Transformers Fix & Optimization Guide
- Dev RAM Calculator
Accuracy Note
Commands and paths reflect common, real-world setups as of 2026-08. Always verify against your installed version and OS. When in doubt, consult the official vLLM documentation.
Calculator Recommended Adjustment Params
Run the Dev RAM Calculator with the values referenced in this guide to validate your rig before and after the fix.