Why Does AI Need So Much RAM? The Memory Math Behind Weights, KV Cache and the 2026 Shortage
If you have shopped for a laptop, a graphics card or a memory kit this year, you have probably noticed that prices went up and that AI gets the blame. The blame is fair, but the reason is worth understanding, because it also explains why a model that "fits" on your machine on paper may still not run.
"RAM" is used loosely in this question. It can mean the system memory in your computer (DRAM), or the memory on a graphics card (VRAM), or the special stacked memory on data-center AI chips (HBM). All three matter, and they matter for the same underlying reasons. This guide walks through those reasons with real arithmetic you can reproduce, then explains how they turned into a global shortage.
The short answer
- A model is a very large table of numbers, and all of it has to be within reach. The weights must sit in fast memory for the model to answer at a usable speed.
- Generating text keeps a running memory of the conversation. That memory, the KV cache, grows with every token and with every user.
- Speed depends on memory bandwidth, not only on capacity. Each generated token requires reading the model's weights, so how fast memory can feed the chip sets the ceiling.
- Training needs several times more memory than running the model. Gradients and optimizer states pile on top of the weights.
Memory item 1: the weights
Every parameter in a model is a number, and every number takes space. The rule is simple:
Memory for weights = number of parameters × bytes per parameter
The bytes per parameter depend on the precision the model is stored in. Standard 16-bit formats use 2 bytes. 8-bit quantization uses 1 byte. 4-bit quantization uses half a byte.
| Model size | 16-bit (2 bytes) | 8-bit (1 byte) | 4-bit (0.5 byte) |
|---|---|---|---|
| 7 billion parameters | 14 GB | 7 GB | 3.5 GB |
| 13 billion parameters | 26 GB | 13 GB | 6.5 GB |
| 70 billion parameters | 140 GB | 70 GB | 35 GB |
These are the weights only. In practice you add roughly 10 to 20 percent for overhead, and you still need room for the KV cache below. A 70-billion-parameter model at 16-bit precision needs 140 GB just for weights, which is more than any single mainstream GPU holds, so it has to be split across several.
This is why quantization is so popular for local use. Dropping from 16-bit to 4-bit cuts weight memory by a factor of four, at some cost in quality. Our does this arithmetic for you.
Memory item 2: the KV cache
When a model generates text, it does not recompute everything from scratch for each new token. It stores intermediate results, called keys and values, for all the earlier tokens in the conversation, so that each new token can look back at them. This is the KV cache. It is one of the stages in our , where you can watch it grow.
The size of the KV cache per token is:
2 × layers × KV heads × head dimension × bytes per value
The 2 is for keys and values. Here is a worked example for a classic 7-billion-parameter design with 32 layers, 32 key-value heads, a head dimension of 128 and 16-bit values (2 bytes):
2 × 32 × 32 × 128 × 2 = 524,288 bytes, or about 0.5 MB per token.
That sounds small until you multiply it out:
- One conversation of 4,096 tokens: about 2 GB.
- 50 users at once, each with 4,096 tokens: about 100 GB.
So a 7B model whose weights take 14 GB can need far more memory than that once it serves many users or very long documents. The KV cache scales with the number of tokens and with the number of simultaneous requests, and long context windows make it worse.
Newer models often reduce this with grouped-query attention, which stores fewer key-value heads. If the same model used 8 KV heads instead of 32, the cache per token would drop by four times, to about 0.125 MB. That is one reason attention design shows up in memory planning, not just in quality.
Memory item 3: the speed limit
Capacity is only half of the story. To produce each new token, the chip must read essentially all of the model's weights out of memory. That makes generation limited by memory bandwidth, not by raw arithmetic speed.
A back-of-the-envelope upper bound for a single stream is:
Tokens per second ≈ memory bandwidth ÷ model size in memory
An H100 SXM GPU has 80 GB of HBM3 with a bandwidth of about 3.35 TB/s, or 3,350 GB/s. For a 7B model at 16-bit (14 GB):
3,350 ÷ 14 ≈ 239 tokens per second, at most, for one stream.
At 4-bit (3.5 GB), the same arithmetic gives about 957 tokens per second as an upper bound. Real systems fall short of these numbers because of the KV cache, overhead and scheduling, so treat them as ceilings. But the pattern is the important part: smaller weights mean faster generation, and faster memory means faster generation. This is why AI chips use HBM rather than ordinary memory.
Memory item 4: training costs several times more
Training needs the weights, plus gradients, plus the optimizer's state. For a common setup with mixed precision and the Adam optimizer, a standard rule of thumb is about 16 bytes per parameter:
- 2 bytes for 16-bit weights
- 2 bytes for 16-bit gradients
- 12 bytes for the optimizer: a 32-bit master copy of the weights plus two 32-bit moment values
For a 7-billion-parameter model, that is 7 billion × 16 bytes ≈ 112 GB, before activations. That is eight times the 14 GB needed to run it. Techniques like LoRA cut this sharply by training only small adapter matrices while the original weights stay frozen. Our lets you compare full fine-tuning and LoRA for your model.
How this became a global shortage
Put those four effects together at data-center scale and you get an appetite for memory that the industry has not seen before.
The chips use a different, more expensive kind of memory. AI accelerators rely on HBM, which stacks several memory layers vertically. IEEE Spectrum reports an estimate that HBM costs roughly three times as much as other types of memory and makes up half or more of the cost of a packaged GPU. Because it is so profitable, manufacturers have shifted production capacity toward it.
That left less capacity for everything else. According to reporting from NPR, analysts at TrendForce estimated that demand for RAM chips exceeded supply by about 10 percent, and that prices were rising quickly. Northeastern University cited Counterpoint Research, which said memory prices jumped about 90 percent in the first quarter of 2026 compared with the previous quarter. And The National reported that a 32 GB memory kit that cost about $52 in June 2025 was selling for around $250 by September 2026.
It is not a quick fix. New factories take years to build. NPR reported that the next new fab, Micron's in Idaho, was expected to come online in 2027, and analysts quoted by IEEE Spectrum say prices could stay elevated even after new capacity arrives. Prices come down more slowly than they go up.
Graphics cards were hit as well, because each one carries several gigabytes of fast memory. If you are wondering why your next PC or GPU costs more, this is a large part of the answer.
What this means if you run models yourself
- Choose hardware by memory first. Check whether the weights fit, then add the KV cache for your context length and number of users, then add 10 to 20 percent. Only then look at speed.
- Quantize when you can. 4-bit versions of many models fit on cards that cannot hold the 16-bit version, with a moderate quality cost.
- Watch context length. A longer context window multiplies the KV cache. If you do not need 100,000 tokens, do not allocate them.
- Consider the Mixture of Experts trade-off. MoE models run fast because only some experts are active, but all of them must sit in memory. We cover this in our guide to .
- Compare against an API. If buying memory for a self-hosted model is expensive, an API may be cheaper at your volume. Our shows where the break-even lies.
- Think about distilled models. A smaller student model trained from a larger one can cut memory needs. See .
Common mistakes
- Checking only whether the weights fit and forgetting the KV cache
- Assuming that more GPU compute fixes a memory problem
- Confusing system RAM with GPU memory, since the model usually needs to live in GPU memory for good speed
- Planning for one user and then serving many
- Forgetting that training needs several times the memory of inference
Frequently asked questions
Is system RAM or GPU memory more important for AI? For running a model at good speed, GPU memory (VRAM or HBM) matters most, because the weights and KV cache need to sit next to the chip doing the math. System RAM matters for loading models, offloading layers that do not fit, and general work, but offloading is much slower.
Why can't AI just use a hard drive or SSD? Storage is far too slow. Generating every token means reading the model's weights, so the speed of the memory they sit in sets how fast the model can respond. An SSD is orders of magnitude slower than HBM.
Will RAM prices come down? Analysts quoted in recent reporting expect prices to stay high for a while, because new factories take years to come online. Check current prices before you plan a purchase.
How much memory do I need to run a 7B model? About 14 GB for the weights at 16-bit precision, around 7 GB at 8-bit and around 3.5 GB at 4-bit, plus room for the KV cache and about 10 to 20 percent overhead. Use the to check a specific setup.