Local LLM VRAM Requirements: A Quantized Model Hardware Guide
Learn how to estimate local LLM memory requirements from model weights, KV cache, and runtime overhead. This guide covers INT4 model sizes, GPU VRAM tiers, Apple Silicon unified memory, troubleshooting steps, and considerations for moving larger workloads to cloud GPUs.
Estimate Memory Before Choosing Hardware
When running a large language model locally, the first question is usually: “How much VRAM does this model need?” Memory figures published by model developers often assume original BF16 weights, while most local users run INT4 or INT8 quantized versions.
The following method helps you estimate memory requirements and choose hardware based on model size, dedicated GPU capacity, or unified memory.
1. The Three Components of VRAM Usage
Use this formula as a starting point:
VRAM ≈ model weights + KV cache + runtime overhead, with roughly 10% additional headroom.
Model weights
Weight memory equals the parameter count multiplied by the number of bytes per parameter:
- BF16: 2 bytes per parameter
- INT8: 1 byte per parameter
- INT4: approximately 0.5 bytes per parameter
Actual INT4 files also store scaling factors, and some layers typically retain higher precision. As a result, file sizes can be roughly 10–15% larger than the theoretical minimum.
KV cache
During generation, the model caches the keys and values associated with previous tokens. Estimate this memory as:
KV cache = 2 × number of layers × number of KV heads × head dimension× context length × concurrent sequences × bytes per element
KV cache grows linearly with context length and concurrency—not exponentially.
For example, Llama-3-8B has 32 layers, 8 KV heads, and a head dimension of 128. With an FP16 cache, it uses approximately 128 KB per token, or about 512 MB for a 4K context.
Older architectures without grouped-query attention (GQA) may need several times as much cache at the same context length. Parameter count alone is therefore not enough to predict memory use.
Runtime overhead
The inference framework, GPU driver context, and compute buffers also consume VRAM. A typical allowance is approximately 1–2 GB, depending on the framework and version.
2. Estimated VRAM by Model Size
The following estimates assume INT4 quantization, a 4K context, and a batch size of 1. Total VRAM includes weights, KV cache, and runtime overhead. The estimates assume models that use GQA.
| Model size | INT4 weights | Estimated total VRAM |
|---|---|---|
| 7B–9B | About 4–5 GB | About 5–7 GB |
| 13B–14B | About 7–9 GB | About 10–12 GB |
| 20B–34B | 20B: about 10–12 GB; 34B: about 18–20 GB | 20B: about 13–15 GB; 34B: about 22–24 GB |
| 70B | About 38–42 GB | About 42–46 GB |
Context length and concurrency change the KV cache requirement. Increasing context from 4K to 32K makes the cache approximately eight times larger. Runtime overhead also varies between inference frameworks, so treat these figures as starting points rather than guarantees.
3. Choosing a Dedicated GPU by VRAM Tier
6 GB GPUs
Start with a 3B–4B INT4 model for more reliable operation.
A 7B–8B INT4 model may fit only if you reduce context to around 2K and close other applications using VRAM. Even then, longer conversations can lead to out-of-memory errors.
8–12 GB GPUs
A 7B–9B INT4 model is a practical choice for 4K–8K contexts. Reserve approximately 1 GB for system and display use.
A 12 GB GPU can also be used to try 13B–14B INT4 models, but keep context at 4K or below because headroom is limited.
16 GB GPUs
A 13B–14B INT4 model has more comfortable headroom at 4K–8K contexts.
A 20B INT4 model may require 13–15 GB, leaving only 1–3 GB available. Monitor VRAM usage closely.
GPUs with 24 GB or More
Models in the 20B–34B range become feasible with INT4 quantization.
A 34B model may require approximately 22–24 GB, putting a 24 GB GPU close to capacity. Be cautious with longer contexts.
A 70B model requires more than 42 GB under these assumptions. It exceeds the capacity of the lower-VRAM single-GPU configurations discussed here and calls for multiple GPUs or a higher-memory professional GPU.
Example: Running a 14B INT4 Model with llama.cpp
./llama-server -m ./models/medium-14b-q4_k_m.gguf -c 4096 -ngl 99
-m: Path to the model file. llama.cpp uses the GGUF format.-c: Context length, which directly affects KV cache size.-ngl: Number of layers to offload to the GPU. A value of 99 requests offloading all layers for models with no more than 99 layers; the value only needs to meet or exceed the model’s layer count.
These options belong to llama.cpp. Frameworks such as vLLM and Ollama use different parameter names or configuration methods, so do not copy them directly.
Troubleshooting Insufficient VRAM
- Estimate before launch. Check that the calculated requirement is below roughly 90% of available VRAM.
- Monitor actual usage. Use
nvidia-smiwhile the model runs. On Windows, you can also check “Dedicated GPU memory” in Task Manager. - Reduce context length. Lower the value of
-c. - Reduce concurrency. Process fewer requests at the same time.
- Offload fewer layers to the GPU. Lower
-nglso that some layers remain on the CPU. The model may run, but generation will be slower. - Use lower-bit quantization. For example, switch from Q4 to Q3, accepting a potential reduction in output quality.
- Close other VRAM-consuming applications. Browser hardware acceleration and video players can consume GPU memory.
On Windows, NVIDIA drivers may move overflow data into system memory. The program may continue without an error, but generation speed can drop sharply. If performance suddenly collapses, check VRAM usage first.
4. Deployment on Unified Memory Systems
On unified memory platforms such as Apple Silicon, the CPU and GPU share the same memory pool. Both total memory capacity and memory bandwidth matter.
According to manufacturer-published specifications, memory bandwidth is approximately:
- Base M4: 120 GB/s
- M4 Pro: 273 GB/s
- M4 Max: 410–546 GB/s, depending on the GPU core configuration
A rough theoretical upper bound for generation speed is memory bandwidth divided by the weight bytes read for each generated token.
An 8B INT4 model of approximately 5 GB has a theoretical upper bound of about 24 tokens per second on a 120 GB/s system. A 32B INT4 model of approximately 19 GB has an upper bound of about 6 tokens per second on the same system. Actual performance is typically lower.
Recommendations by Unified Memory Capacity
- 16 GB: The operating system and other applications consume a significant share of memory. A 7B–9B INT4 model can run, but 13B–14B models leave very little headroom and are not recommended as the primary model.
- 32 GB: A 13B–14B model has more comfortable memory headroom, and a 20B INT4 model can run. A 34B model requiring approximately 22–24 GB may exceed macOS’s default GPU memory allowance, roughly two-thirds to three-quarters of total memory. Manual adjustment may be necessary and carries additional risk.
- 64 GB: A 34B model fits comfortably. A 70B INT4 model requiring approximately 42–46 GB can fit, but leaves limited headroom once other memory use is considered. Memory bandwidth can also make generation slow.
When memory runs short, the system may compress data or swap it to the SSD, causing a sharp slowdown. In Activity Monitor, yellow or red “Memory Pressure,” or steadily increasing “Swap Used,” indicates that a smaller model may be necessary.
5. When Local Hardware Is Not Enough: Cloud GPU Scaling
If local hardware cannot accommodate a 70B model, or you need to serve several users at once, renting cloud GPUs is an alternative.
Cloud providers, including Baidu AI Cloud, offer GPU server and container instance options. Choose an instance with enough memory for the model, and verify service availability for your intended deployment location.
Before renting, review the following:
- GPU memory capacity: Account for model weights, KV cache, and headroom. For multi-GPU deployments, also check inter-GPU bandwidth.
- Billing model: Pay-as-you-go, monthly, and spot pricing can differ substantially. Spot instances may be reclaimed and are better suited to batch jobs that can retry. Test the actual workload with pay-as-you-go billing before committing to a monthly plan.
- Weight storage: Model files can be stored in object storage. Check how quickly instances can load them, along with outbound data charges associated with model downloads and inference results.
- Data compliance: Confirm whether business data may be processed in the cloud or transferred across borders, and whether the deployment meets applicable industry requirements. Also verify that the model license permits commercial use.
- Portability and lock-in: Package the inference service in a container and prefer common interfaces, such as OpenAI-compatible APIs, to simplify a move back to local hardware or to another provider.
- Monitoring: Track VRAM usage, throughput, and time to first token. Retain logs to support troubleshooting.
6. Predeployment Checklist
- Choose the model size and quantization format. Estimate weight memory from the parameter count and bytes per parameter.
- Calculate KV cache requirements. Use the longest expected context and maximum concurrency, then include 1–2 GB of runtime overhead and approximately 10% headroom.
- Compare the estimate with hardware capacity. Aim to keep the total requirement below roughly 90% of available GPU or unified memory.
- Measure after launch. Monitor actual VRAM or system memory usage and record the peak.
- Respond to OOM errors or sudden slowdowns. Reduce context length, concurrency, or GPU-offloaded layers, or switch to lower-bit quantization.
- Evaluate cloud deployment if needed. Consider cloud GPUs when the workload exceeds local hardware limits.
