GPU Memory Planning and Hardware Selection for Local LLM Deployment
This article explains how to estimate GPU memory for local LLM deployment beyond theoretical weight size. It breaks down weight memory, KV cache, runtime buffers, and batching overhead; discusses quantization caveats; maps common parameter-scale tiers to hardware from 6 GB GPUs to 24 GB+ and unified-memory systems; and provides a practical workflow for stress testing peak usage, reserving headroom, and avoiding configurations that load but do not run stably.
Many local deployment tutorials provide a “theoretical VRAM” number. In practice, the most common concern is not whether a model can be downloaded, but whether a given machine can run it stably: Will VRAM run out when the context grows? Does low-bit quantization still require extra buffers? Official or documentation theoretical values are usually based on the original weight format and often under-cover quantized deployment, long context, batching, and runtime overhead. This article is therefore not centered on a specific model. It starts from general technical questions and explains where GPU memory is spent in local LLM deployment, how to estimate it, how to choose hardware by tier, and how to avoid the pitfall of “it loads, but it does not run stably.”
1. Quick Reference by Parameter-Scale Tier
The table below gives empirical ranges. It assumes common low-bit quantization, single-stream conversation or light batching, and context length within a moderate range. Actual usage is affected by the quantization implementation, runtime framework, context length, batch size, and memory fragmentation. The table should not be treated as guaranteed values.
| Model scale tier | Empirical VRAM range after quantization | Recommended hardware tier | Suitable scenarios |
|---|---|---|---|
| ~2B-parameter minimal model | ~2–4 GB | Lightweight machines with up to 4 GB | Validate the minimal runnable path and API integration |
| ~4B-parameter efficient model | ~4–6 GB | Start with a 6 GB GPU or 16 GB unified memory | First local experience for most users |
| ~26B total-parameter sparse-activated model | ~12–16 GB | 16 GB tier is more comfortable | Stronger local reasoning without moving to the heaviest models |
| ~31B-parameter dense model | ~20–24 GB | 24 GB and above | Generation quality, coding ability, and long context |
It is important to emphasize that “it starts” does not mean “it runs stably.” Startup only loads weights. Long-context inference, concurrent requests, and batch tasks quickly push up the KV cache, temporary activations, and runtime buffers. Hardware selection should be based on peak VRAM, not on whether loading succeeds.
2. Where GPU Memory Is Spent
Local inference GPU memory usage can be roughly divided into four parts:
- Weight memory: determined by parameter count and quantization bit width. Lower bit width reduces weight memory, but not all computation is performed at low bit width; dequantization and fused operators may still create temporary buffers.
- KV cache: the longer the context and the larger the batch size, the more noticeable the cache usage. Scenarios such as long-document question answering and code repository analysis must be estimated separately.
- Runtime and temporary buffers: including computation graph optimization, operator workspace, memory alignment, and memory fragmentation. Different runtime implementations vary considerably, and headroom beyond weights is usually required.
- Batching and concurrency overhead: single-stream conversation and multi-user concurrency are not the same. The higher the concurrency, the more easily caches and temporary buffers are amplified.
A general estimation approach is as follows:
Total VRAM ≈ weight memory × (1 + redundancy factor)+ KV cache+ runtime buffers+ batch activationsWeight memory ≈ parameter count × bytes per parameter ÷ 1024^3Bytes per parameter ≈ quantization bit width ÷ 8KV cache ≈ layers × KV heads × head dimension × context length× batch size × bytes per element × 2
A redundancy factor of at least 20%–30% is recommended to cover memory fragmentation, operator temporary buffers, and additional overhead from different implementations. When context length doubles, KV cache usually increases significantly. If concurrency is also enabled, peak usage may be much higher than single-stream test results.
3. Quantization Is Not Just “Smaller Files”
Low-bit quantization can significantly reduce weight memory, but several details matter during deployment:
- Embedding and output layers may be more sensitive: some implementations keep these layers at higher precision, so actual usage may be higher than a simple “parameter count × bit width” estimate.
- Group quantization and calibration data affect results: quantization granularity, calibration samples, and algorithm implementation affect quality and stability. Do not look only at the bit-width number.
- Dequantization has temporary overhead: low-bit weights may be dequantized to higher precision during computation, so runtime buffers cannot be ignored.
- Long context amplifies cache: quantization mainly compresses weights and has limited effect on KV cache compression. Long-context scenarios require separate evaluation of cache strategy.
- Layer offload is only a fallback: placing some layers in host memory or unified memory can avoid immediate VRAM exhaustion, but it introduces bandwidth bottlenecks and higher latency. It is not suitable as a stable high-throughput solution.
Therefore, when you see “about a few GB after 4-bit quantization,” keep asking: How long is the context? What is the batch size? Is concurrency enabled? How much runtime headroom is reserved? Is layer offload used? Only when these conditions are clear does a VRAM number have reference value.
4. Choosing by GPU Tier
1. Around 6 GB GPUs: Prioritize Small Efficient Models
This tier is suitable for a ~4B-parameter efficient model, which usually falls in the 4–6 GB range after quantization. Start with a shorter context and single-stream requests, and reserve more than 20% VRAM headroom. Do not default to a 26B-tier or 31B-tier model. Although extreme quantization and layer offload “might” allow startup, speed, stability, and long-context experience are difficult to guarantee. The goal at this tier is to validate the local pipeline, prompt behavior, and basic chat capability.
2. 8–12 GB GPUs: Small Models Are More Stable; Mid-Size Models Need Careful Evaluation
8–12 GB can run ~4B-parameter models more comfortably and can also be used to evaluate low-bit versions of mid-size models. However, note that context length and runtime overhead will consume headroom. Start with single-stream, short-context runs, then gradually increase length and record peak VRAM. Do not choose a configuration that sits at the VRAM limit; otherwise, a single long-document input may trigger failure.
3. 12–16 GB GPUs: Mid-Size Sparse-Activated Models Enter the Serious Trial Range
A ~26B total-parameter sparse-activated model is more worth discussing at this tier. Sparse activation architectures have a large total parameter count but activate fewer parameters per inference, so their memory and compute characteristics differ from dense models. Even so, at the 16 GB tier you should monitor actual inference speed, first-token latency, and long-context performance. Starting successfully does not mean stable operation. Stress test with real business inputs rather than looking only at nominal specifications.
4. 24 GB and Above GPUs: Large Dense Models Are Worth Trying
A ~31B-parameter dense model usually requires 20–24 GB or even more VRAM. The 24 GB+ tier can be seriously evaluated, but long context will still significantly increase cache usage. For code generation, long-document analysis, and high-quality question answering, prioritize stable headroom and reduce batch size or context length when necessary. VRAM tables are references, not guarantees; the same model may show clearly different peak usage under different runtimes and quantization implementations.
5. How to Evaluate Unified-Memory Devices
Unified memory architectures are not measured by discrete VRAM alone. Look at total system memory capacity, memory bandwidth, and memory pressure. As a rule of thumb:
- 16 GB unified memory: suitable as a starting point for a ~4B-parameter efficient model. Mid-size models can be tried but are usually slower, mainly due to bandwidth limits.
- 18–32 GB unified memory: small models run more smoothly, and mid-size sparse-activated models can be tried. The 32 GB tier offers a noticeable improvement over 16 GB.
- 64 GB and above unified memory: both mid-size models and large dense models have room to run, suitable for users with quality requirements who do not want a discrete GPU.
Unified-memory devices require particular attention to the misconception that “memory is VRAM.” The system, applications, model weights, and cache share the same pool. If background programs consume too much, the model may be swapped to disk, appearing as a sudden slowdown or even a freeze. Before deployment, close unnecessary background tasks, monitor memory pressure, and leave enough headroom for the system.
6. An Executable Selection and Tuning Workflow
It is recommended to proceed as follows:
- Define the business goal: Is it API integration, daily chat, code generation, or long-document analysis? Different goals impose different quality and context requirements.
- Start with a small model to validate the pipeline: Use a ~4B-parameter efficient model to get input/output, logging, monitoring, and exception handling working.
- Stress test peak usage with real inputs: Record VRAM or memory peaks at four stages: after loading, first inference, long context, and concurrent requests.
- Increase context gradually: Start from 2K or 4K, observe KV cache growth, and do not max it out all at once.
- Limit batch size and concurrency: Increase concurrency only after single-stream operation is stable, avoiding stacked cache and temporary buffers.
- Reserve 20%–30% headroom: Leave space for runtime, fragmentation, and burst requests.
- Monitor and alert: In a team environment, keep model files in object storage, use a container platform for environment isolation, and observe VRAM and memory peaks through monitoring and alerting. If you use Baidu AI Cloud, treat general-purpose compute and storage capabilities only as an elastic validation environment; final decisions should still be based on peak usage on the target machine.
- Use layer offload only as a fallback: When VRAM is insufficient, layer offload can avoid immediate failure, but it reduces speed and is not recommended as a long-term high-throughput solution.
A simplified deployment configuration example is as follows:
deployment_profile:model_scale: "40b_efficient"weight_bits: 4context_tokens: 4096batch_size: 1reserve_ratio: 0.25offload_policy: "none"monitor:peak_vram: truepeak_host_memory: true
7. Conclusion
GPU memory configuration for local LLM deployment is essentially a system estimation problem covering weights, cache, runtime, and headroom. A ~4B-parameter efficient model is suitable for most users’ first local experience. A ~26B total-parameter sparse-activated model is worth serious attempts at the 12–16 GB tier and above. A ~31B-parameter dense model is better suited to the 24 GB+ tier, and users should accept the additional overhead of long context. Unified-memory devices require attention to both capacity and bandwidth; do not look only at the memory number. The safest approach is to start with low context and single-stream requests, stress test peak usage with real inputs, reserve sufficient headroom, and then decide whether to move up to a larger model tier.
