RUNLOCALAIv38
->Will it run?Best GPUCompareTroubleshootStartLearnPulseModelsHardwareToolsBench
Run check
RUNLOCALAI

Independently operated catalog for local-AI hardware and software. Hand-written verdicts. Source-cited claims. Reproducible commands when we have them.

OP·Eruo Fredoline
DIR
  • Models
  • Hardware
  • Tools
  • Benchmarks
TOOLS
  • Will it run?
  • Compare hardware
  • Cost vs cloud
  • Choose my GPU
  • Prompting kits
  • Quick answers
REF
  • All buyer guides
  • Learn local AI
  • Methodology
  • Glossary
  • Errors KB
  • Trust
EDITOR
  • About
  • Author
  • How we make money
  • Editorial policy
  • Contact
LEGAL
  • Privacy
  • Terms
  • Sitemap
MAIL · MONTHLY DIGEST
Get monthly local AI changes
Monthly recap. No spam.
DISCLOSURE

Some links on this site are affiliate links (Amazon Associates and other first-class retailers). When you buy through them, we earn a small commission at no extra cost to you. Affiliate links do not influence our verdicts — there are cards we rate highly that we don't have affiliate relationships with, and cards that sell well that we refuse to recommend. Read more →

© 2026 runlocalai.coIndependently operated
RUNLOCALAI · v38
  1. >
  2. Home
  3. /Learn
  4. /How-to
  5. /How to configure vLLM GPU memory allocation
HOW-TO · SET

How to configure vLLM GPU memory allocation

intermediate·15 min·By Eruo Fredoline
Target environment
Ubuntu 24.04 · Ollama 0.4.xWindows 11 · Ollama 0.4.xmacOS 15 · Ollama 0.4.x
PREREQUISITES

vLLM installed, single or multi-GPU setup

What this does

Controls how much of each GPU's VRAM is allocated to model weights versus the KV cache during inference. Proper allocation balances throughput against memory errors to maximize GPU utilization.

Steps

  1. Determine total GPU VRAM. Knowing available memory guides every subsequent setting.

    nvidia-smi --query-gpu=memory.total,memory.free --format=csv
    

    Expected output: a table listing total and free VRAM per GPU in MiB.

  2. Set the GPU memory utilization fraction. The --gpu-memory-utilization flag reserves a fraction of free VRAM for the KV cache.

    vllm serve <model> \
      --gpu-memory-utilization 0.85 \
      --max-model-len 8192
    

    Expected output: server starts, KV cache arena allocated to the target utilization.

  3. Tune max model length separately. The max_model_len parameter constrains the context window and indirectly controls per-sequence memory footprint.

    vllm serve <model> \
      --max-model-len 4096 \
      --gpu-memory-utilization 0.85
    

    Expected output: context window capped at 4096 tokens.

  4. Set block size for KV cache granularity. The default of 16 works for most cases.

    vllm serve <model> \
      --block-size 16 \
      --gpu-memory-utilization 0.85
    

    Expected output: server logs display the block size as configured.

Verification

curl -s http://localhost:8000/v1/models | python -m json.tool
# Expected: model listed, confirming server started with configured memory budget

Common failures

  • CUDA out of memory at startup — --gpu-memory-utilization set too high. Reduce to 0.75 or 0.7.
  • max_model_len exceeds available memory — Lower max_model_len until startup succeeds without OOM.
  • GPU utilization below 50% — Utilization fraction is too low. Raise --gpu-memory-utilization in steps of 0.05.
  • Multi-GPU memory imbalance — CUDA_VISIBLE_DEVICES ordering may not match NCCL expectations.

Operator checkpoint

Before treating this as solved, write down the local runtime, model or package version, hardware/backend if relevant, and the verification output. This keeps the guide useful as a Will-It-Run style decision instead of a one-off command transcript.

Related guides

  • How to enable tensor parallelism in vLLM
  • How to optimize vLLM for throughput
  • Course Local AI Fundamentals
RELATED GUIDES
SET
How to enable tensor parallelism in vLLM
SET
How to optimize vLLM for throughput
← All how-to guidesCourses →