Local and Private AI
Local LLM Hardware Guide: How Much VRAM and RAM You Really Need
By Amjid Ali · · 8 min read

In this article
The memory a local LLM needs is easy to estimate: parameters (in billions) × bits per weight ÷ 8 = gigabytes of weights, plus the KV cache for your context, plus about a gigabyte of runtime overhead. At the common Q4_K_M quantization (about 4.9 bits per weight), that is roughly 0.6 GB per billion parameters: about 5 GB for an 8B model, 16.5 GB for 27B and 43 GB for 70B, before context. Whatever hardware you buy, memory capacity decides which models you can run; memory bandwidth decides how fast they generate.
Quick answer
| You have | Comfortable model size at 4-bit | Examples |
|---|---|---|
| 8 GB GPU or 8 GB Mac | Up to about 8B | Gemma 4 E4B, small Qwen3.5 sizes |
| 12 to 16 GB | 12B to 20B | Gemma 4 12B, gpt-oss 20B |
| 24 GB | 24B to 27B with moderate context | Devstral Small 2, Qwen3.8 27B |
| 32 GB | 27B to 35B with longer context | Gemma 4 31B, Qwen3.6 35B-A3B |
| 64 GB | 70B dense, or 80B MoE coders | Qwen3-Coder-Next (52 GB) |
| 128 GB and up | 100B+ MoE models | gpt-oss 120B (65 GB), larger MoE models |
Step 1: memory for the weights
Each parameter is stored with a certain number of bits. Full-precision checkpoints use 16 bits (2 bytes). Quantization stores them with fewer bits, trading a little quality for a lot of memory.
NVIDIA's inference guide gives the baseline: a 7B model at 16-bit needs "roughly 7B * sizeof(FP16) ~= 14 GB". llama.cpp publishes the effective bits per weight of its GGUF formats, measured on Llama 3.1 8B:
| Format | Bits per weight | Size vs 16-bit |
|---|---|---|
| F16 | 16.00 | 100% |
| Q8_0 | 8.50 | 53% |
| Q6_K | 6.56 | 41% |
| Q5_K_M | 5.70 | 36% |
| Q4_K_M | 4.89 | 31% |
| IQ4_XS | 4.46 | 28% |
| Q3_K_M | 4.00 | 25% |
K-quants mix precisions across tensors, which is why Q4_K_M lands at 4.89 bits rather than exactly 4.
Weights-only sizing table
Using GB = parameters (billions) × bits per weight ÷ 8:
| Model size | F16 | Q8_0 | Q6_K | Q5_K_M | Q4_K_M |
|---|---|---|---|---|---|
| 3B | 6.0 GB | 3.2 GB | 2.5 GB | 2.1 GB | 1.8 GB |
| 8B | 16.0 GB | 8.5 GB | 6.6 GB | 5.7 GB | 4.9 GB |
| 14B | 28.0 GB | 14.9 GB | 11.5 GB | 10.0 GB | 8.6 GB |
| 27B | 54.0 GB | 28.7 GB | 22.2 GB | 19.2 GB | 16.5 GB |
| 32B | 64.0 GB | 34.0 GB | 26.3 GB | 22.8 GB | 19.6 GB |
| 70B | 140.0 GB | 74.4 GB | 57.4 GB | 49.9 GB | 42.8 GB |
| 120B | 240.0 GB | 127.5 GB | 98.4 GB | 85.6 GB | 73.4 GB |
These match published numbers closely. llama.cpp lists Llama 3.1 70B at 43.1 GB in Q4_K_M, and Google's Gemma 4 docs give 17.5 GB for the 31B model at 4-bit and 69.9 GB at BF16. Real downloads run a little larger when a model includes a vision encoder or keeps some layers at higher precision.
Some models ship in other formats. OpenAI's gpt-oss quantizes its expert weights to MXFP4 at about 4.25 bits per parameter, which is why the 20B model is a 14 GB download.
Mixture of experts: load everything, compute a little
A mixture-of-experts model such as Gemma 4 26B A4B or Qwen3.6 35B-A3B activates only a few billion parameters per token, but all experts must be in memory. Google's docs note the 26B A4B needs memory close to a dense 26B model (14.4 GB at 4-bit). Use the total parameter count for memory and the active count as a rough guide to speed.
Step 2: memory for the KV cache
During generation, the model stores a key and a value vector for every token, in every layer, so it does not recompute them. That is the KV cache, and it grows with context length.
NVIDIA's formula, per token:
KV bytes per token = 2 × layers × (KV heads × head dimension) × bytes per value
The 2 is for keys and values. Most modern models use grouped-query attention, which means fewer KV heads than attention heads, and a much smaller cache. Worked examples at 16-bit (2 bytes), using each model's published config.json:
| Model | Layers | KV heads × head dim | Per token | 8k context | 32k context |
|---|---|---|---|---|---|
| Llama 2 7B (no GQA, NVIDIA's example) | 32 | 32 × 128 | 512 KiB | 4 GiB | 16 GiB |
| Qwen2.5 7B | 28 | 4 × 128 | 56 KiB | 0.44 GiB | 1.75 GiB |
| Qwen2.5 32B | 64 | 8 × 128 | 256 KiB | 2 GiB | 8 GiB |
NVIDIA's Llama 2 7B example (sequence length 4096) works out to about 2 GB; the table doubles that for 8k. The Qwen2.5 32B row is the one to remember: a 32B model at Q4_K_M (about 19.6 GB) plus a 32k context (8 GiB) does not fit on a 24 GB card, even though the weights alone do.
Newer architectures reduce this further. Qwen3.8, for example, mixes Gated DeltaNet layers with standard attention layers, and linear-attention layers like DeltaNet keep a fixed-size state rather than a growing cache. Check the model's config before assuming the worst.
Ways to shrink the KV cache
- Use a shorter context when you do not need a long one. Ollama sets 4k tokens by default on GPUs under 24 GiB, 32k from 24 to 48 GiB and 256k above that. It recommends at least 64k for agents and coding, so budget for it.
- Quantize the cache. Ollama's
OLLAMA_KV_CACHE_TYPE=q8_0uses about half the memory of f16, andq4_0about a quarter, when flash attention is enabled. - Check placement with
ollama ps. A CPU/GPU split means something spilled out of VRAM.
Step 3: add overhead
Leave headroom for the runtime's compute buffers and for whatever your OS, display and other apps already use. On a Mac the model shares unified memory with macOS and everything else you have open, so a 64 GB Mac cannot give all 64 GB to a model.
Full example: Qwen3.8 27B is an 18 GB download on Ollama. On a 32 GB GPU or Mac that leaves well over 10 GB for a 64k context and overhead. On a 24 GB card the margin is about 6 GB, so keep the context modest or quantize the KV cache.
Choosing hardware
NVIDIA GeForce GPUs
NVIDIA's own spec comparison lists:
| Card | VRAM |
|---|---|
| RTX 5090 | 32 GB GDDR7 |
| RTX 5080 | 16 GB GDDR7 |
| RTX 5070 Ti | 16 GB GDDR7 |
| RTX 5070 | 12 GB GDDR7 |
| RTX 5060 Ti | 16 GB or 8 GB GDDR7 |
| RTX 5060 | 8 GB GDDR7 |
| RTX 4090 | 24 GB GDDR6X |
| RTX 3090 | 24 GB GDDR6X |
For LLMs, VRAM matters more than gaming performance. A 16 GB RTX 5060 Ti holds more model than a 12 GB RTX 5070, and the older 24 GB RTX 3090 and 4090 hold more than any current 16 GB card. Ollama supports NVIDIA cards with compute capability 5.0 or higher.
Two GPUs can split a model across their combined VRAM in llama.cpp and Ollama, and llama.cpp's CPU+GPU hybrid mode can run models larger than VRAM, at a big speed cost for the part on the CPU.
Apple Silicon Macs
Macs share one pool of unified memory between CPU and GPU, so the GPU can use most of the system RAM. That is the Mac's advantage: capacity. Apple's current Mac Studio specs:
| Chip | Unified memory options | Memory bandwidth |
|---|---|---|
| M5 Max | 36 GB, configurable to 48, 64 or 128 GB | 460 GB/s, or 614 GB/s with the 40-core GPU |
| M5 Ultra | 96 GB, configurable to 256 or 512 GB | 1.2 TB/s |
A 128 GB Mac can load models no single consumer GPU can. LM Studio requires Apple Silicon and macOS 14 or newer, and recommends 16 GB or more. MLX builds of models, available in LM Studio and Ollama's library, are optimized for these chips.
NVIDIA DGX Spark and similar boxes
NVIDIA's DGX Spark has 128 GB of unified LPDDR5x memory at 273 GB/s, and NVIDIA says it handles models up to 200 billion parameters (100 billion on the 64 GB OEM configuration). It is aimed at developers who want large-model capacity on a desk, with CUDA.
AMD GPUs
Ollama supports AMD cards through ROCm v7 on Linux and a narrower set (mainly RX 7000 and PRO W7000 series) on Windows, plus Vulkan for broader coverage. llama.cpp supports AMD through HIP and Vulkan.
Capacity vs speed: what bandwidth means
To generate each token, the hardware has to read the active weights from memory. That makes generation speed roughly proportional to memory bandwidth divided by the bytes read per token. Two consequences, without inventing benchmark numbers:
- A model that fits in fast VRAM generates much faster than one that spills into system RAM. Avoid splits.
- MoE models generate faster than dense models of the same total size, because each token reads only the active experts.
Prompt processing (reading a long input) is compute-bound instead, which is where discrete GPUs pull ahead. If you want to see real speeds, measure on your own machine: same model, same quantization, same context, several runs.
Buying advice by budget of memory
- Already own a laptop with 16 GB? Start there. gpt-oss 20B and Gemma 4 12B run fine. See how to run an LLM locally.
- Building a desktop for local AI? Prioritize VRAM: 16 GB minimum, 24 to 32 GB to run the best 24B to 31B coding models with real context. Our best local LLM for coding guide lists them.
- Want the biggest models on one quiet box? A Mac with 64 to 128 GB or a 128 GB unified-memory system.
- Serving several users? Look at vLLM on Linux with NVIDIA or AMD GPUs; it is built for high-throughput serving.
Tools differ less than people think on the same hardware. If you are deciding between apps, see Ollama vs LM Studio.
Frequently asked questions
How much VRAM do I need to run an LLM locally?+
Multiply the parameter count in billions by the bits per weight and divide by 8 to get gigabytes of weights, then add the KV cache for your context. At 4-bit (Q4_K_M) that is about 0.6 GB per billion parameters, so an 8B model needs about 5 GB and a 27B model about 16.5 GB before context.
Do I need a GPU to run an LLM locally?+
No. llama.cpp and Ollama run models on a CPU, and small models are usable that way. For models above a few billion parameters at a comfortable speed, you want a GPU with enough VRAM or an Apple Silicon Mac, whose unified memory acts as GPU memory.
Is a Mac good for running local LLMs?+
Yes, especially for large models. Apple Silicon shares one pool of unified memory between CPU and GPU, and current Mac Studio models offer up to 128 GB (M5 Max) or 512 GB (M5 Ultra), far more than any single consumer GPU. NVIDIA GPUs usually generate faster for models that fit in their VRAM.
What is the KV cache and why does it need memory?+
The KV cache stores attention keys and values for every token in the conversation so the model does not recompute them. It grows linearly with context length, so long contexts for coding agents can need several extra gigabytes on top of the model weights.
Is 16 GB of RAM enough for a local LLM?+
Yes for small and mid-size models. 16 GB comfortably holds 8B to 14B models at 4-bit, and Ollama says gpt-oss 20B runs on systems with as little as 16 GB. For 27B to 32B models with a useful context, aim for 24 to 32 GB.
Q4 vs Q8: which quantization should I use?+
Q4_K_M is the usual default: about 4.9 bits per weight, roughly 30 percent of the size of 16-bit. Q8_0 (about 8.5 bits) is closer to full quality but needs about 75 percent more memory than Q4_K_M. If the larger model fits only at Q4, the larger model at Q4 is usually the better choice.
Sources
- llama.cpp quantize: bits per weight and sizes, ggml-org
- Mastering LLM Techniques: Inference Optimization, NVIDIA
- Gemma 4 model overview (memory requirements), Google
- Qwen2.5-7B-Instruct config.json, Qwen (Hugging Face)
- Qwen2.5-32B-Instruct config.json, Qwen (Hugging Face)
- Ollama FAQ, Ollama
- Context length, Ollama
- Hardware support, Ollama
- gpt-oss on Ollama, Ollama
- Compare GeForce graphics cards, NVIDIA
- NVIDIA DGX Spark, NVIDIA
- Mac Studio technical specifications, Apple
- LM Studio system requirements, LM Studio
- Qwen3.8-27B model card, Qwen (Hugging Face)
- vLLM Quickstart, vLLM
The weekly AI briefing
Get the guides like this one, once a week
Keep reading
Local and Private AIBest Local LLM for Coding in 2026 (Picked by Your Hardware)The best local coding models for 16, 24-32 and 64 GB+ machines, with sizes, licenses and vendor benchmarks, plus how to plug them into Claude Code or your IDE. · 7 min read
Local and Private AIOllama vs LM Studio: Which Local LLM Tool Should You Use?Ollama is the open-source, CLI-first runner for developers; LM Studio is the polished desktop app. Compare engines, APIs, platforms and licensing, and pick one. · 7 min read
Local and Private AIHow to Run an LLM Locally in 2026: Tools, Hardware and ModelsRun an LLM on your own computer: compare Ollama, LM Studio, llama.cpp, vLLM and Jan, size memory for any model, set up Ollama step by step and pick a model. · 9 min read