Local LLM VRAM Requirements: Choosing Hardware for 4B to 31B Models
Learn how to estimate memory requirements for local LLM inference, including quantized weights, KV cache, activations, and runtime overhead. This guide compares 4B lightweight models, 26B mixture-of-experts models, and 31B dense models across GPU VRAM tiers and unified-memory devices, with a practical workflow for testing stability and performance.
Local LLM VRAM Requirements: Choosing Hardware for 4B to 31B Models
When deploying a large language model locally, the first question is often not “How good is this model?” but “Can my hardware run it?”
Documentation may provide theoretical memory requirements for unquantized weights. In practice, most local deployments use 4-bit or 8-bit quantization, and memory consumption also depends on context length, batch size, inference runtime overhead, and memory fragmentation. Theoretical weight size is therefore a starting point—not a reliable minimum requirement for running a model.
This guide covers three representative categories: lightweight 4B models, 26B mixture-of-experts (MoE) models, and 31B dense models. The central principle is simple: choose hardware using a complete memory budget, not parameter count alone.
1. Build a Complete VRAM Budget
Local inference memory usage can be divided into five components:
- Model weights: Memory occupied by the parameters. At 4-bit precision, the theoretical requirement is approximately 0.5 bytes per parameter. Actual usage also includes quantization scales, higher-precision layers, embeddings, and other overhead.
- KV cache: Memory that grows linearly, or approximately linearly, with context length and batch size. It is particularly easy to underestimate for long-context workloads.
- Peak activations: Temporary tensors created during forward computation. Their size depends on batch size, sequence length, and model architecture.
- Runtime overhead: Memory used by the inference framework, acceleration backend, communication buffers, and memory pools.
- Fragmentation and headroom: Allocator fragmentation, other processes, and driver reservations reduce usable memory. A practical configuration should generally leave 10–20% headroom.
A simplified budget is:
VRAM budget ≈ model weights+ KV cache+ peak activations+ fixed runtime overhead+ fragmentation and safety headroom
Weight memory can be estimated as:
Weight memory ≈ parameter count × bits per parameter / 8 × overhead factor
A 4B model at 4-bit precision has a theoretical weight size of about 2 GB. That does not mean it will run within 2 GB of VRAM: quantization metadata, higher-precision components, KV cache, and runtime buffers all require additional space.
A simplified KV cache estimate is:
KV cache ≈ 2 × number of layers × number of KV heads × head dimension× sequence length × batch size × bytes per element
Grouped-query attention, cache reuse, and paged cache management can affect actual usage. The main relationship remains unchanged: longer contexts and larger batches increase KV cache requirements.
This explains why a model may work for short conversations but run out of memory during long-document question answering or concurrent requests.
2. Estimated Memory Ranges by Model Size
The following ranges are rough screening estimates for 4-bit quantization, a moderate context length, and a single request. They are not guaranteed minimum requirements.
| Model size and type | Approximate memory usage | Suggested hardware tier | Typical use cases |
|---|---|---|---|
| Around 2B, edge-oriented | 2–4 GB | Lightweight devices with roughly 4 GB available | Verifying a minimal deployment, simple classification, short-text tasks |
| Around 4B, lightweight | 4–6 GB | 6 GB discrete GPU or 16 GB unified memory as a starting point | First local deployment, everyday conversation, lightweight question answering |
| 26B MoE, around 4B active parameters | 12–16 GB | 16 GB provides more headroom | Stronger local reasoning without moving to the heaviest model tier |
| 31B dense | 20–24 GB | 24 GB or more | Quality-focused generation, coding, and longer-context workloads |
Three distinctions matter when interpreting these ranges.
MoE Models Still Need Memory for All Expert Weights
A 26B MoE model activates only part of its parameters for a given token. This reduces active computation relative to a similarly sized dense model, but it does not eliminate the need to store the full expert weights.
Its memory footprint and computational workload therefore need to be considered separately. A low active-parameter count does not make its weight-memory requirements equivalent to those of a 4B model.
Dense Models Put More Direct Pressure on Capacity and Bandwidth
A 31B dense model uses all of its parameters during inference. Its larger weights and computational workload place greater demands on memory capacity and bandwidth.
A 24 GB GPU is a reasonable tier for experimentation, but long contexts and larger batches can still exceed available VRAM.
Quantization Has Trade-Offs
Four-bit quantization substantially reduces weight memory, but it can affect output quality, inference speed, and compatibility.
For coding, mathematics, or long-document summarization, compare 4-bit and 8-bit versions on your actual tasks rather than choosing solely by memory usage.
3. Choosing a Model by GPU VRAM Tier
6 GB GPUs: Start with a Lightweight 4B Model
A 6 GB GPU is an entry-level option for local LLM inference. A 4B model with 4-bit quantization is a sensible starting point.
Larger 26B or 31B models are not necessarily impossible to experiment with, but treating them as the default choice can lead to out-of-memory errors, heavy paging, or very slow inference.
Recommended approach:
- Start with a 4B model at 4-bit precision and a moderate context length.
- Close unnecessary graphics-intensive applications to reduce competing memory usage.
- If you must try a larger model, consider CPU offloading or a unified-memory device, while expecting lower speed.
- Verify stable generation with short prompts before increasing context length.
8–12 GB GPUs: A Comfortable Starting Point for 4B Models
With 8–12 GB of VRAM, 4B models generally have more room to operate. Some larger models may also be worth testing with low-bit quantization.
However, 12 GB does not automatically make a 26B model practical. Context length and runtime overhead can substantially change the result.
Recommended approach:
- Use a 4B model as a stable baseline for everyday tasks.
- When testing a 26B MoE model, start with a short context, one request, and a small batch.
- Monitor peak VRAM rather than selecting a configuration that barely fits.
- If memory runs out, first reduce context length, then consider lower-bit quantization or partial layer offloading.
12–16 GB GPUs: A Practical Testing Range for 26B MoE Models
This tier makes 26B MoE models a more serious option. The important question is not merely whether the model loads, but whether it remains stable during real workloads.
Successful loading does not establish that long conversations, long documents, or batched requests will fit.
Recommended approach:
- Prefer 16 GB for more headroom; 12 GB requires tighter configuration control.
- Start with 4-bit quantization and a batch size of 1–2.
- Stress-test long-context tasks separately and record peak memory at different sequence lengths.
- Measure actual inference speed rather than relying only on model specifications. MoE throughput can vary substantially across workloads.
GPUs with 24 GB or More: Explore 31B Dense Models
A GPU with at least 24 GB of VRAM makes 31B dense models worth exploring, particularly when generation quality, coding ability, or longer contexts are priorities.
These capacity estimates are still not guarantees. Long contexts increase KV cache usage, while larger batches can increase peak activations.
Recommended approach:
- Consider a 31B model at 4-bit precision as a quality-focused local option.
- Reserve extra memory for long contexts rather than planning around short-chat measurements.
- For coding and document workloads, test realistic input lengths.
- Track peak VRAM, throughput, time to first token, and generation speed.
4. Evaluating Unified-Memory Devices
On unified-memory systems, the CPU and GPU share the same physical memory rather than using separate system RAM and dedicated VRAM.
These devices can offer substantial shared capacity, but memory bandwidth may be lower than that of a high-end discrete GPU. The operating system and other applications also draw from the same pool.
The selection priority is therefore: available unified memory first, then bandwidth and cooling.
| Unified memory | Suggested model size | Considerations |
|---|---|---|
| 16 GB | Start with 4B; 26B may be marginal and slow | Suitable for everyday conversation; larger models face tight available-memory and bandwidth constraints |
| 18 GB | Prefer 4B; evaluate 26B case by case | Leave room for the operating system and other applications |
| 32 GB | More room for 4B; 26B MoE is worth testing | A meaningful improvement over 16 GB for larger models |
| 64 GB | Capacity for testing both 26B and 31B models | An option for quality-focused local inference without a discrete GPU |
Keep three limitations in mind:
- Installed memory is not fully available to the model. The operating system, browser, and background services share it.
- Bandwidth affects usability. Enough capacity does not guarantee satisfactory generation speed.
- Cooling and power limits affect sustained performance. A brief generation test may not reflect performance during extended inference.
5. Context Length and Batch Size Are Hidden Variables
Many disagreements about whether a model “fits” come from testing different context lengths or batch sizes.
A 4B model might use around 4 GB during a short conversation, yet consume considerably more memory during long-context, multi-turn, or batched inference because of KV cache growth.
The following pseudocode provides a rough planning estimate:
function estimate_vram(params_b, bits_per_param, layers, kv_heads, head_dim,seq_len, batch, runtime_overhead_gb, safety_ratio):weights_gb = params_b * 1e9 * bits_per_param / 8 / 1e9kv_cache_gb = 2 * layers * kv_heads * head_dim * seq_len * batch * 2 / 1e9subtotal = weights_gb + kv_cache_gb + runtime_overhead_gbreturn subtotal * (1 + safety_ratio)
This simplified calculation assumes two bytes per KV cache element. It does not separately account for quantization metadata or peak activations, so it should not be treated as a precise capacity prediction.
Its purpose is to show that parameter count is only the first term: sequence length and batch size can change the overall budget significantly.
For deployment planning, measure peak memory at several context lengths and build a capacity curve for your own configuration.
6. A Practical Stress-Testing and Tuning Workflow
Hardware selection should not rely on a table alone. Use a repeatable testing process:
- Establish a baseline. Run a 4B model at 4-bit precision with a short context and one request. Record memory usage, time to first token, and generation speed.
- Increase context length gradually. Move from short prompts to medium-length inputs and long documents. Record how peak memory changes.
- Increase batch size. Test batches of 1, 2, and 4 while monitoring throughput and peak memory to find a stable operating point.
- Use real workloads. Evaluate representative prompts rather than relying exclusively on fixed examples.
- Leave headroom. Avoid configurations that sit directly at the memory limit. Aim to retain 10–20% spare capacity.
- Monitor and document results. Track peak memory, out-of-memory events, throughput, and latency. Save the configuration so results can be reproduced.
7. Common Misconceptions
“Four-Bit Memory Usage Is Just Parameter Count Divided by Two”
That gives only the theoretical weight size in bytes. Actual usage also includes quantization metadata, higher-precision components, runtime buffers, and KV cache.
“If the Model Loads, It Will Run Reliably”
Loading successfully is not a stability test. Longer contexts and larger batches can create memory peaks that do not appear during initialization or short prompts.
“Enough Unified Memory Is All That Matters”
Capacity is only one requirement. Bandwidth, cooling, and competing system usage also affect whether a model is practical to use.
“Model Size Alone Determines Hardware Requirements”
Short conversations, long-document analysis, code completion, and batch summarization place different demands on context length and batch size. Hardware planning must reflect the intended task.
8. Conclusion
Choose hardware for local LLM inference using the full memory budget:
Weights + KV cache + activations + runtime overhead + safety headroom.
For most users, a 4B model with 4-bit quantization is a sensible starting point on a 6–12 GB GPU. The 12–16 GB tier is worth evaluating for 26B MoE models, while GPUs with 24 GB or more are better suited to exploring 31B dense models.
For unified-memory devices, prioritize available memory, bandwidth, and sustained thermal performance rather than installed capacity alone.
Start with a small, stable baseline, test real tasks at realistic context lengths, and make the final decision using measured peak memory—not parameter count alone. Memory tables help narrow the options; workload testing establishes what your system can reliably handle.
