Local LLM VRAM Guide: Choosing Models by Parameter Size and Quantization
This guide explains how to estimate GPU memory requirements for running large language models locally. It covers the main VRAM consumers—model weights, KV cache, and runtime overhead—how quantization changes memory usage, approximate VRAM ranges for common model sizes, and how to choose a configuration based on available GPU memory and context length.
1. Why VRAM Is the First Bottleneck for Local Inference
When running large language models locally, the main limitation is often not CPU compute but whether the GPU has enough VRAM. VRAM is high-speed memory dedicated to the GPU. If memory usage exceeds the physical limit, an inference request may fail outright or fall back to a much slower swap mode. In that case, the model may appear to load but still be effectively unusable.
For this reason, the first step in selecting a model is not simply looking at its parameter count. It is estimating how much VRAM the model will require at a given quantization level, while also leaving room for runtime overhead.
2. What Consumes VRAM: Three Main Components
The VRAM used by local inference is generally made up of three parts:
Model weights
This is usually the largest component. Its size is relatively easy to estimate because it depends on the number of parameters and the number of bytes used per parameter.KV cache
During autoregressive generation, frameworks cache the Key and Value tensors for each layer to avoid repeatedly computing past tokens. The KV cache grows approximately linearly with context length, batch size, and number of layers. In long-context scenarios, it can even exceed the memory used by the model weights themselves.Runtime overhead
This includes activations, temporary buffers, and memory reserved by the framework for its own management. It typically takes around 1–2 GB.
Many users only calculate the size of the model weights and ignore the other two components. As a result, the weights may appear to fit, but the system can still run out of VRAM during real conversations.
3. Quantization: Trading Precision for Memory Savings
The same model can use very different amounts of VRAM at different quantization levels. A simple way to estimate weight size is by looking at bytes per parameter:
- FP16 (half precision): about 2 bytes per parameter
- INT8 (8-bit quantization): about 1 byte per parameter
- INT4 (4-bit quantization): about 0.5 bytes per parameter
For example, a model with around 7B parameters takes up nearly 14 GB in FP16, but can be reduced to around 4 GB with INT4 quantization.
The benefit of quantization is a major reduction in VRAM usage. The trade-off is that it may cause some loss of precision. For most local-use scenarios, INT4 is a cost-effective choice. For cases where output quality is the top priority, higher precision and a larger VRAM budget may be preferable.
4. Approximate VRAM Requirements by Parameter Size
The table below gives approximate VRAM reference ranges for typical model sizes, assuming quantization around INT4. These are practical estimates and may vary depending on implementation and configuration.
| Parameter size | Approximate VRAM after quantization | Recommended starting VRAM | Typical use cases |
|---|---|---|---|
| Around 2B | 2–4 GB | 4 GB class | Validating a minimal runnable pipeline |
| Around 4B | 4–6 GB | A 6 GB GPU or a 16 GB unified-memory device | First local experience for most users |
| Around 26B, including sparse activation architectures | 12–16 GB | 16 GB is more comfortable | Stronger reasoning without choosing the heaviest models |
| Around 31B | 20–24 GB | 24 GB or more | Higher quality, code generation, and long-context use |
The phrase “including sparse activation architectures” refers to a class of Mixture-of-Experts (MoE) designs. These models may have a large total parameter count, but only part of the parameters is activated for each token. As a result, their VRAM usage sits between that of their total parameter count and a much smaller model. They cannot be estimated by simply converting the total parameter count.
5. Choosing a Configuration by VRAM Capacity
6 GB class GPUs:
Prioritize models around 4B parameters. Models around 26B or 31B may be technically possible, but starting there is likely to hit VRAM limits quickly and make debugging difficult.8 GB–12 GB class GPUs:
Models around 4B parameters run more comfortably. You can also evaluate lower-precision versions of medium-sized models. Avoid configuring systems right at the VRAM limit; leave enough room for context length and runtime overhead.12 GB–16 GB class GPUs:
Models around 26B, including MoE designs, enter a range where serious experimentation is possible. Being able to load a model does not mean it will run smoothly. Pay close attention to actual generation speed rather than relying only on paper specifications.24 GB or more:
Models around 31B parameters are worth trying. However, the VRAM table is a reference, not a guarantee. Long contexts can still significantly increase memory usage.
6. The Hidden Variable: Context Length
The impact of context length on VRAM is often underestimated. KV cache usage grows with sequence length. Increasing the context from 2K to 32K can increase cache usage by more than ten times.
For this reason, when selecting a GPU, it is better to work backward from the total of three items:
- model weights
- estimated KV cache for the target context length
- runtime overhead
Looking only at weight size is a common reason why a configuration that appears runnable on paper can still fail during real long-text tasks.
7. How to Estimate VRAM Usage
The following is a framework-agnostic example for making an initial VRAM estimate:
def estimate_vram_gb(params_b, bits, seq_len,num_layers, hidden_dim, batch=1, kv_bits=16):# 1) Weight memoryweight_gb = params_b * 1e9 * (bits / 8) / (1024 ** 3)# 2) KV cache memorykv_bytes = 2 * num_layers * hidden_dim * seq_len * batch * (kv_bits / 8)kv_gb = kv_bytes / (1024 ** 3)# 3) Runtime overhead (rule of thumb)overhead_gb = 1.5return weight_gb + kv_gb + overhead_gb# Example: ~7B model, INT4 quantization, 32K context# print(estimate_vram_gb(7, 4, 32768, num_layers=32, hidden_dim=4096))
After comparing the estimated result with the target GPU’s VRAM, it is good practice to leave about 20% headroom. This helps determine whether a configuration is safe and avoids the common situation where a system works almost perfectly in testing but fails when put into real use.
8. Local or Cloud: Making the Trade-off
When local VRAM is insufficient, there are two common options. One is to move to a GPU with more memory. The other is to run inference in the cloud.
Cloud environments can provide on-demand GPU compute. Combined with general cloud capabilities such as object storage, logging, and monitoring alerts, cloud inference can avoid a large upfront hardware investment. This can be suitable for workloads with variable traffic or for scenarios that require elastic scaling.
Local deployment, on the other hand, can offer advantages in data privacy, offline availability, and long-term cost.
When deciding between local and cloud deployment, it is best to weigh factors such as cost, latency, and compliance requirements, then choose the deployment path that best fits the business.
