VRAM Requirements for Local LLMs: A Complete Sizing and Hardware Selection Guide
Learn how to accurately estimate VRAM for running large language models locally. This guide breaks down model weights, KV cache, activation memory, and runtime overhead, provides a reusable estimation formula with sample code, explains the real impact of quantization and context length, and offers practical hardware recommendations for GPUs and unified-memory devices.
VRAM Requirements for Local LLMs: A Complete Sizing and Hardware Selection Guide
When deploying large language models locally, the most common question is not “can I download the model,” but “how much VRAM does this machine actually need.” Public documentation typically lists theoretical values based on BF16 or FP16 raw weights, but real-world deployments usually rely on 4-bit, 5-bit, or 8-bit quantization, plus KV cache, temporary activations, inference runtime overhead, driver and framework usage, and the extra memory demanded by long contexts. Simply multiplying “parameter count × bytes per parameter” tends to underestimate actual requirements.
This article does not focus on any specific model or product. Instead, it provides a reusable VRAM estimation method and a hardware selection framework. Whether you are running lightweight models, small dense models, or medium-sized sparse-activation and mid-to-large dense models, you can apply the same “VRAM ledger” to make decisions.
1. Build a VRAM Ledger: Don’t Just Count Weights
VRAM consumption during local inference can be broken down into four parts:
- Model weights: determined by parameter count and quantization bit-width — the most intuitive component.
- KV cache: strongly correlated with layer count, hidden dimension, attention head configuration, context length, and batch size. It grows significantly with long contexts.
- Temporary activations and compute buffers: intermediate tensors, operator workspaces, and batch-processing scratch space during inference.
- Runtime overhead and safety margin: the inference framework, drivers, memory alignment, VRAM fragmentation, and peak fluctuations all consume extra space.
A simplified formula for an initial estimate:
Total VRAM ≈ weight memory + KV cache + temporary activations + runtime overhead + safety marginWeight memory ≈ parameter count × bytes per parameter × alignment factorKV cache ≈ 2 × layers × sequence length × batch size × KV head dimension × bytes per element
Under 4-bit quantization, “bytes per parameter” is theoretically about 0.5 bytes, but in practice it is affected by scaling factors, group quantization, memory alignment, and unquantized layers. Applying an alignment factor of 1.05–1.15 is recommended. For KV cache, pay close attention to whether the architecture uses grouped-query attention; even when the weights fit, long contexts can push total usage up by several GB.
Below is a framework-agnostic sample estimation script for building a first-pass budget:
def estimate_vram_gb(params_billion,bits_per_weight=4,seq_len=4096,batch_size=1,layers=32,kv_heads=8,head_dim=128,kv_bytes=2,runtime_overhead_gb=1.2,safety_ratio=0.15,):# Weights: parameter count × bits / 8, accounting for alignment# and unquantized layer overheadweight_gb = params_billion * 1e9 * bits_per_weight / 8 / (1024 ** 3)weight_gb *= 1.10# KV cache: the factor of 2 accounts for K and V; simplified structurekv_gb = (2 * layers * seq_len * batch_size * kv_heads * head_dim * kv_bytes/ (1024 ** 3))base = weight_gb + kv_gb + runtime_overhead_gbtotal = base * (1 + safety_ratio)return {"weight_gb": round(weight_gb, 2),"kv_cache_gb": round(kv_gb, 2),"runtime_overhead_gb": runtime_overhead_gb,"recommended_vram_gb": round(total, 2),}
The point of this code is not to produce exact numbers, but to force you to include “context length” and “safety margin” in your budget. Many out-of-memory failures are not caused by weights exceeding capacity, but by KV cache ballooning when context grows from 2K to 8K or 16K.
2. Quantization Saves VRAM, but It Is Not Unconditionally Free
Quantization is the core technique for local deployment. 4-bit quantization typically compresses weight memory to roughly a quarter of BF16, and 8-bit to about half. But quantization is not “lossless compression” — keep three things in mind:
- Quantization granularity: group-wise versus per-channel quantization affects both accuracy and extra metadata overhead.
- Unquantized layers: embedding layers, output layers, or some normalization layers may remain at higher precision, so actual usage exceeds the pure theoretical value.
- Runtime dequantization: computation may require temporary dequantization buffers, making peak VRAM higher than static weight usage.
Therefore, when you see “about X GB after 4-bit quantization,” treat it as the lower bound for weights, not the upper bound for what the machine can run. On VRAM-constrained devices, prefer moderate context lengths, single concurrency, smaller batch sizes, and disable unnecessary prefill caching or high-overhead features.
3. Selecting Hardware by Tier
The table below gives rough empirical ranges for “around 4-bit quantization, moderate context, single concurrency.” Actual numbers vary with quantization scheme, context length, inference runtime, and hardware platform — always verify with real measurements.
| Model Category | Approx. Quantized Weight VRAM | Recommended Hardware Tier | Typical Use Case |
|---|---|---|---|
| Lightweight (hundreds of millions to ~1B params) | ~2–4GB | Lightweight devices under 4GB | Validating the minimal working pipeline, low-resource experiments |
| Small (~4B class) | ~4–6GB | 6GB-class GPU or 16GB unified-memory device as a starting point | Most people’s first local experience |
| Medium sparse-activation (~20B total params, ~4B active) | ~12–16GB | 16GB tier for comfortable headroom | Stronger local reasoning without the heaviest models |
| Mid-to-large dense (~30B class) | ~20–24GB | 24GB and above | Prioritizing quality, code, and long context |
Lightweight devices under 4GB: prioritize lightweight models; the goal is to get the pipeline working and validate the inference runtime and I/O flow. Don’t challenge medium-sized models at the start, or you’ll burn time on out-of-memory errors and repeated retries.
~6GB GPUs: small models are the safer starting point. Medium or larger models are not absolutely off-limits, but they should not be the default choice. Pay special attention to context length and desktop display usage — usable VRAM is often less than the nominal figure.
8GB–12GB GPUs: small models run more reliably, and you can evaluate aggressively quantized versions of medium models. Beware the risk of “cutting it too close”: the desktop, browser, and inference framework all consume VRAM, so reserve 1–2GB of headroom.
12GB–16GB GPUs: medium sparse-activation models enter the seriously viable range. Being able to launch does not mean running stably — focus on actual inference speed, peak VRAM under long context, and sustained-run stability.
24GB+ GPUs: mid-to-large dense models become worth trying. But a VRAM table is a reference, not a guarantee. Long contexts, multiple concurrent sessions, and larger batch sizes still increase memory usage significantly.
4. How to Choose Unified-Memory Devices
Unified-memory architectures are not measured by dedicated VRAM; instead, look at total unified memory, memory bandwidth, and system usage. As a rule of thumb:
| Unified Memory Tier | Recommended Model Category | Notes |
|---|---|---|
| 16GB | Small models as the baseline; medium models with caution | Fine for everyday chat; larger models are limited mainly by bandwidth and system overhead |
| 32GB | Small models run smoothly; medium sparse models are viable | Noticeably better experience than the 16GB tier |
| 64GB | Both medium and mid-to-large models can run | Suits users with quality requirements who don’t want a discrete accelerator |
| ~18GB | Small models preferred; medium depending on conditions | Leave sufficient headroom for the system and runtime |
The advantage of unified memory is large capacity and simple deployment; the downside is that memory bandwidth typically falls short of discrete accelerators. A model fitting in memory does not mean fast generation. For interactive use, prioritize time-to-first-token and tokens per second rather than capacity alone.
5. Context Length and Concurrency Are Hidden Costs
Many selection tables only state “how much VRAM the model needs” while ignoring context and concurrency. KV cache grows linearly with sequence length and linearly with batch size. Raising context from 4K to 16K can multiply KV cache several times over; going from one to four concurrent sessions amplifies usage the same way.
Practical recommendations:
- Get things working at 2K–4K context first, then scale up toward your target length.
- Record peak VRAM at different context lengths rather than only checking whether startup succeeds.
- Reserve a larger safety margin for long-context scenarios — 20%–30% is recommended.
- For multi-concurrency scenarios, run stress tests and watch for VRAM fragmentation and tail latency.
6. Measurement Methodology: Start from the Minimal Working Path
Validate in the following order:
- Minimal path: smallest model, shortest context, single concurrency — confirm the runtime and I/O work correctly.
- Target model: switch to the target model and quantization version, then record static memory usage after loading.
- Gradual stress: incrementally increase context length and batch size, recording peak VRAM and speed.
- Stability observation: run continuously for a period and watch for failures caused by fragmentation or cache growth.
- Leave headroom: the final configuration should retain 15%–30% VRAM headroom to avoid instability from system updates or load fluctuations.
For batch deployment on the enterprise side, you can combine general-purpose container platforms, monitoring and alerting, and object storage capabilities — such as those offered by Baidu AI Cloud — for model distribution, runtime isolation, and resource monitoring. However, actual capacity should still be determined through measurement against your target model, quantization scheme, context length, and concurrency.
Conclusion
VRAM planning for local LLMs cannot be based solely on parameter count and theoretical weight size. The right approach is to build a complete ledger of “weights + KV cache + temporary activations + runtime overhead + safety margin,” then match model categories to hardware tiers. Lightweight devices should start with small models; the 6GB–12GB tier should prioritize small models; 12GB–16GB makes medium sparse-activation models seriously viable; and 24GB+ is where mid-to-large dense models belong. For unified-memory devices, evaluate capacity and bandwidth together. Final selection should be based on measured peak VRAM and stable inference speed, not on copying a static VRAM table.
