Can RTX 4090 24GB run Gemma 4 31B?
Measured results for Gemma 4 31B (31.27B dense) on RTX 4090 24GB, plus what fits and the commands to run it.
Short answer
Yes. Gemma 4 31B Q4_K_M fits fully on RTX 4090 24GB at 16k context, using 20.5 of 23.0 GB usable, and generates about 44.4 tokens/s in our own run. As the context fills it slows down: 40.1 tok/s with 16k tokens already in context (90% of the empty-context speed), measured. For Q4_K_M, our bandwidth-only estimate was ~30 tok/s against a measured median of ~44 (32% too pessimistic).
Cite this
Please attribute our measurements to Matt and Local LLM Advisor. Own runs and curated tables are CC BY 4.0; third-party rows keep their upstream licenses.
Matt. "Gemma 4 31B on RTX 4090 24GB." Local LLM Advisor, https://localllmadvisor.com/can-run/gemma-4-31b-on-rtx-4090-24gb.html. Dataset: https://huggingface.co/datasets/LocalLLMAdvisor/local-llm-advisor-benchmarks (CC BY 4.0).
Dataset on Hugging Face · Sources and licenses
Measured generation speed by quantization
| Quant | Generation tok/s | Range | Prompt tok/s | Runs | Origin |
|---|---|---|---|---|---|
| Q4 class (median) | 44.4 | 44.4–44.4 | 2403 | 1 | includes our runs |
| Q4_K_M (our run, depth 0) | 44.4 | 3 repeats | 2403 | 3 | own measurement |
Generation = tg128 (128 generated tokens, short context). Public rows are medians of community llama.cpp results (sources); our own runs use llama-bench b11658 on a rented GPU.
Speed vs context depth measured
Our own llama-bench runs on GeForce RTX 4090 (flash attention on, 3 repeats): generation and prompt speed with the given number of tokens already in the context.
| Quant | Context depth | Generation tok/s | vs depth 0 | Prompt tok/s |
|---|---|---|---|---|
| Q4_K_M | 0 | 44.4 | 100% | 2403 |
| Q4_K_M | 4k | 41.8 | 94% | 2285 |
| Q4_K_M | 16k | 40.1 | 90% | 1960 |
Alternatives
Less memory that still fits Gemma 4 31B
Smaller memory usually means a cheaper card or Mac (we do not list prices).
- Mac mini M6 32GB Amazon: Q4_K_M, 22 GB usable, ~6 tok/s estimated
- MacBook Pro 14 M6 32GB Amazon: Q4_K_M, 22 GB usable, ~6 tok/s estimated
- MacBook Air M5 32GB Amazon: Q4_K_M, 22 GB usable, ~6 tok/s estimated
Faster for Gemma 4 31B
- RTX 5090 32GB Amazon: Q6_K, 31 GB usable, ~55 tok/s measured
Other models on RTX 4090 24GB, similar size
- GLM-4.7-Flash (hardware page): Q5_K_M, fits fully, ~257 tok/s (scaled from measured)
- Qwen3-Coder 30B-A3B: Q4_K_M, fits fully, ~266 tok/s (measured)
- Laguna XS 2.1 (hardware page): Q4_K_M, fits fully, ~191 tok/s (scaled from measured)
- Qwen3.6 27B: Q5_K_M, fits fully, ~42 tok/s (scaled from measured)
Memory and context limits
Q4_K_M weights are 18.3 GB; the 16k f16 KV cache adds 2.18 GB. Largest context that fits in 23.0 GB usable:
| KV cache type | Max context |
|---|---|
| f16 | 32k |
| q8_0 | 64k |
| q4_0 | 128k |
Native limit 256k. Full KV cache table for Gemma 4 31B.
Copy-paste commands
The advisor's pick for this hardware: Q4_K_M, 16k context.
llama-server -hf unsloth/gemma-4-31B-it-GGUF:Q4_K_M -c 16384 -fa on --jinja -ngl 99
OLLAMA_CONTEXT_LENGTH=16384 ollama serve ollama run hf.co/unsloth/gemma-4-31B-it-GGUF:Q4_K_M
FAQ
How fast is Gemma 4 31B on RTX 4090 24GB?
About 44.4 tokens/s for generation (Q4_K_M on llama.cpp CUDA, 128-token generation), 2403 tokens/s for prompt processing. Speed drops as the context fills; see the depth table.
How much memory does Gemma 4 31B need on RTX 4090 24GB?
The advisor's pick, Q4_K_M, is 18.3 GB of weights plus 2.18 GB of KV cache at 16k context (20.5 GB), against 23.0 GB usable.
Is the Gemma 4 31B speed on RTX 4090 24GB measured or estimated?
Measured: our own llama-bench run on a rented GeForce RTX 4090, including runs with 4k to 16k tokens already in context.
What can I use instead of RTX 4090 24GB for Gemma 4 31B?
With less memory, Mac mini M6 32GB (~6 tok/s), MacBook Pro 14 M6 32GB (~6 tok/s), MacBook Air M5 32GB (~6 tok/s) also fit it fully. Faster: RTX 5090 32GB (~55 tok/s).
What is the maximum context for Gemma 4 31B on RTX 4090 24GB?
With an f16 KV cache about 32k tokens, 64k with q8_0 and 128k with q4_0, bounded by the model's own limit.
Related
All models on RTX 4090 24GB · Gemma 4 31B on all hardware · VRAM tier · all measured pages · leaderboard
Compare: RTX 3090 24GB vs RTX 4090 24GB · RTX 4090 24GB vs RTX 5090 32GB · RTX 4090 24GB vs AMD RX 7900 XTX 24GB · RTX 5080 16GB vs RTX 4090 24GB