Gemma 2 9B IT: how much VRAM does it need?

Gemma 2 9B IT has 9.24B parameters in 42 layers. It uses grouped-query attention: 16 query heads share 8 key-value heads, so its KV cache is 2× smaller than full multi-head attention would need. It takes up to 8,192 tokens of context; one user at that length needs 2.63 GiB of KV cache at FP16 on top of the weights. Its repository is gated on Hugging Face, so LLMScale ships its architecture in a bundled database.

BF16 · 8k context · one user
22.48 GiB

17.21 GiB of weights, 2.63 GiB of KV cache and 2.64 GiB of vLLM's overhead. At INT4 the same workload needs 11.09 GiB.

  • 42 layers
  • hidden 3584
  • 16/8 heads
  • head_dim 256
  • 8k max context

Gemma 2 9B IT memory by precision and context

Precision8k context
BF1622.48 GiBKV cache 2.63 GiB
FP814.73 GiBKV cache 2.63 GiB
INT411.09 GiBKV cache 2.63 GiB

One user, FP16 KV cache and vLLM's overhead on one GPU at its defaults for a card under 70 GB. Quantizing shrinks the weights, not the KV cache, so the saving narrows as the context grows.

Which single GPUs hold it

At 8k context for one user, the smallest cards first. A discrete card is budgeted at vLLM's default 92% of its memory, a unified-memory device at the share its GPU can address, and each carries vLLM's overhead at its own defaults.

How many users fit

Users at 8k context each, on one card. ✗: the weights leave no room for even one.

Fine-tuning Gemma 2 9B IT

MethodMemorySmallest GPU
Full fine-tune139.3 GiBApple M2 Ultra
LoRA (rank 16, attention)19.01 GiBNVIDIA L4
QLoRA (rank 16, attention)6.24 GiBRTX 3060

Sequence length 2,048, batch size 1, gradient checkpointing on, Adam. Full fine-tuning keeps 16 bytes per parameter before activations; QLoRA stores the frozen base in 4-bit NF4.

Where the numbers come from

Weights are parameters × bytes per parameter. The KV cache is 2 × layers × key-value heads × head dimension × bytes × context × users. For Gemma 2 9B IT that is 336.0 KiB per token at FP16. 21 of its 42 layers attend over a sliding window of the last 4,096 tokens and hold no more than that, so past it each further token adds 168.0 KiB, the other 21 layers' share. These are capacity-planning figures: the serving engine — vLLM, TGI, llama.cpp — and its paged-attention efficiency still move the real number.

More on KV cache size and on GQA, MQA and MLA.

Work with Gemma 2 9B IT

Other Gemma models