VRAM · Local model
Gemma 4 31B VRAM requirements: can you run it locally?
Yes, on one 24 GB GPU such as the Radeon RX 7900 XTX, or a Mac with 32 GB of unified memory. At Q4_K_M and an 8K context it needs about 21 GB. At 8-bit (Q8_0) it needs about 36 GB, which fits a 48 GB card. Estimates from the model’s official config.json, checked 2026-10-08.
- Parameters
- 31.3B
- Layers
- 60
- Max context
- 262,144
- Experts
- Dense
Attention: 10 full-attention layers, 50 sliding-window layers (last 1,024 tokens).
Requirements
How much VRAM does Gemma 4 31B need?
| Quantisation | 8K context | 32K context | 128K context | 256K context |
|---|---|---|---|---|
| FP16 / BF16 | 66 GB | 68 GB | 76 GB | 87 GB |
| Q8_0 (8-bit) | 36 GB | 38 GB | 46 GB | 57 GB |
| Q6_K | 28 GB | 30 GB | 38 GB | 49 GB |
| Q5_K_M | 24 GB | 26 GB | 35 GB | 46 GB |
| Q4_K_M | 21 GB | 23 GB | 31 GB | 42 GB |
| Q3_K_M | 18 GB | 20 GB | 28 GB | 39 GB |
| Q2_K | 14 GB | 16 GB | 25 GB | 36 GB |
Weights + FP16 KV cache + overhead, batch 1; the VRAM calculator shows the formula.
GPUs
Which GPUs can run Gemma 4 31B?
| Memory | Example card | Best quality at 8K | Longest context at that quality | Longest context at Q4_K_M |
|---|---|---|---|---|
| 8 GB | GeForce RTX 4060 | Doesn’t fit | — | — |
| 12 GB | GeForce RTX 5070 | Doesn’t fit | — | — |
| 16 GB | GeForce RTX 5080 | Q2_K · 14 GB | 28K | — |
| 24 GB | Radeon RX 7900 XTX | Q4_K_M · 21 GB | 41K | 41K |
| 32 GB | GeForce RTX 5090 | Q6_K · 28 GB | 56K | 134K |
| 48 GB | L40S | Q8_0 (8-bit) · 36 GB | 152K | 256K |
| 80 GB | H100 80GB | FP16 / BF16 · 66 GB | 175K | 256K |
| 96 GB | RTX PRO 6000 Blackwell | FP16 / BF16 · 66 GB | 256K | 256K |
The smallest card that holds Gemma 4 31B at Q4_K_M with an 8K context has 24 GB, such as the Radeon RX 7900 XTX; there it has room for about 41K tokens. Every extra gigabyte goes to context: on a 32 GB card the limit rises to 134K. For 8-bit or better you need a 48 GB card, and full 16-bit precision (66 GB) fits from 80 GB. Cards with 8 and 12 GB can’t hold it at any quantisation with an 8K context; the smallest file, Q2_K, needs about 14 GB.
Apple Silicon
Can you run Gemma 4 31B on a Mac?
| Mac memory | GPU can use | Best quality at 8K | Longest context |
|---|---|---|---|
| 16 GB | 11 GB | Doesn’t fit | — |
| 24 GB | 16 GB | Q2_K · 14 GB | 28K |
| 32 GB | 21 GB | Q4_K_M · 21 GB | 10K |
| 36 GB | 27 GB | Q5_K_M · 24 GB | 38K |
| 48 GB | 36 GB | Q8_0 (8-bit) · 36 GB | 12K |
| 64 GB | 48 GB | Q8_0 (8-bit) · 36 GB | 152K |
| 96 GB | 72 GB | FP16 / BF16 · 66 GB | 82K |
| 128 GB | 96 GB | FP16 / BF16 · 66 GB | 256K |
| 192 GB | 144 GB | FP16 / BF16 · 66 GB | 256K |
| 256 GB | 192 GB | FP16 / BF16 · 66 GB | 256K |
| 512 GB | 384 GB | FP16 / BF16 · 66 GB | 256K |
At Q4_K_M and an 8K context, Gemma 4 31B needs a Mac with at least 32 GB of unified memory; 8-bit needs 48 GB and full precision needs 96 GB. By default macOS lets the GPU use about two thirds of memory on Macs with 32 GB or less and about three quarters on larger ones; the table uses that limit. You can raise it with sudo sysctl iogpu.wired_limit_mb, leaving at least 8 GB for macOS.
Context
How much memory does Gemma 4 31B’s context use?
| Context | KV cache, FP16 | KV cache, 8-bit | Total at Q4_K_M |
|---|---|---|---|
| 8,192 | 1.4 GB | 0.7 GB | 21 GB |
| 32,768 | 3.3 GB | 1.7 GB | 23 GB |
| 131,072 | 11 GB | 5.7 GB | 31 GB |
| 262,144 | 21 GB | 11 GB | 42 GB |
Gemma 4 31B’s FP16 cache grows by about 78 MB for every 1,000 tokens once its windowed layers are full. At 8K tokens that is 1.4 GB, 7% of the total at Q4_K_M; at its full 262,144-token context it is 21 GB, 1.2× the size of the 18 GB of Q4_K_M weights. 50 of its 60 layers use a sliding window of 1,024 tokens, so their cache is full after 1,024 tokens; only the 10 full-attention layers keep growing. On a 24 GB card at Q4_K_M, the longest context is about 41K tokens with an FP16 cache and 86K with an 8-bit (q8_0) cache.
Download
How big is the Gemma 4 31B download?
| GGUF quantisation | Bits per weight | Approximate size |
|---|---|---|
| FP16 / BF16 | 16.00 | 58 GB |
| Q8_0 (8-bit) | 8.50 | 31 GB |
| Q6_K | 6.56 | 24 GB |
| Q5_K_M | 5.70 | 21 GB |
| Q4_K_M | 4.89 | 18 GB |
| Q3_K_M | 4.00 | 15 GB |
| Q2_K | 3.16 | 12 GB |
A 31.3B-parameter model takes about 18 GB of disk at Q4_K_M and 58 GB as 16-bit weights, so the quantised file saves about 40 GB. Sizes are parameters × bits per weight; real GGUF files differ by a few per cent because some tensors stay at higher precision.
Offload
Can you run Gemma 4 31B with less VRAM by offloading to RAM?
| GPU VRAM | In system RAM | RAM to have |
|---|---|---|
| 8 GB | 13 GB | 16 GB |
| 16 GB | 5.1 GB | 16 GB |
Yes: llama.cpp can keep part of Gemma 4 31B in system RAM and run it on the CPU, so the GPU and RAM together need about 21 GB at Q4_K_M and an 8K context. On an 8 GB card that leaves 13 GB in RAM. As a dense model, every token reads all 31.3B parameters, so each layer moved to RAM (fewer --n-gpu-layers) is limited by RAM bandwidth and generation slows as more of it leaves the GPU.
Compare
How does Gemma 4 31B compare with other Gemma models?
| Model | Parameters | Type | Q4 at 8K | Smallest GPU | Context on 24 GB |
|---|---|---|---|---|---|
| Gemma 3 4B | 4.3B | Dense | 3.7 GB | 8 GB | 128K |
| Gemma 3 12B | 12.2B | Dense | 8.8 GB | 12 GB | 128K |
| Gemma 4 26B-A4B | 25.8B | Dense | 17 GB | 24 GB | 256K |
| Gemma 3 27B | 27.4B | Dense | 18 GB | 24 GB | 74K |
| Gemma 4 31B | 31.3B | Dense | 21 GB | 24 GB | 41K |
Gemma 4 31B is number 5 by size of the 5 Gemma models we cover. The next smaller, Gemma 3 27B, needs about 18 GB at Q4 with an 8K context.
FAQ
Frequently asked questions
How much VRAM does Gemma 4 31B need?
With an 8K context, about 21 GB at Q4_K_M, 36 GB at 8-bit (Q8_0) and 66 GB at full 16-bit precision. That covers the weights, the KV cache and runtime overhead.
Can Gemma 4 31B run on a 24 GB GPU like the RTX 4090?
Yes: the best quality that fits with an 8K context is Q4_K_M, at about 21 GB, and at that setting it has room for about 41K tokens.
Can I run Gemma 4 31B on a Mac?
Yes: at Q4_K_M and an 8K context it fits a Mac with 32 GB of unified memory using macOS’s default GPU memory limit (about 21 GB for the GPU).
Can Gemma 4 31B run on 16 or 12 GB?
Best quality with an 8K context: 16 GB: Q2_K at about 14 GB, with up to 28K tokens; 12 GB: no (even Q2_K needs 14 GB).
How big is the Gemma 4 31B download?
About 18 GB for a Q4_K_M GGUF, 31 GB at Q8_0 and 58 GB for the 16-bit weights.
What is the longest context Gemma 4 31B can use on 24 GB?
About 41K tokens at Q4_K_M with an FP16 cache, or 86K with an 8-bit cache. Its maximum is 262,144 tokens.
Related
Try other settings
Try other settings in the VRAM calculator
- Prefer the API? Gemma 4 31B pricing
- Guide: How much VRAM do you need to run an LLM locally?
- Glossary: Quantisation, GGUF, KV cache
Keep exploring