Skip to content

Try local GPU's before you buy them at Vast.ai

Vast.ai

The local AI publication

Google · Released April 2026

Gemma 4 31B

What it takes to run Gemma 4 31B locally: memory by quantization, the GPUs that handle it, and how fast it runs.

Updated

Parameters
31B
Architecture
Dense
Context
256K tokens
License
Apache 2.0 license
Memory at Q4_K_M
~22GB

What do you need to run Gemma 4 31B?

Gemma 4 31B needs about 22GB of VRAM at Q4_K_M with 8K context (20GB for the weights plus KV cache and overhead). The smallest GPU that can hold it is a 20GB card like the RTX 4000 Ada at Q3_K_M, with little memory to spare. For a good balance of price and speed we recommend the RTX 5090 (~59 tokens/sec).

See the full hardware guide for Gemma 4 31B

What to buy

GPUs for Gemma 4 31B

Full hardware guide

Cheapest that runs it

RTX 4000 Ada

20GB · $1,250 MSRP

Quant
Q3_K_M
Speed (est.)
~18 tok/s
Fits, tight

Best value

RTX 5090

32GB · ~$4,300

Quant
Q5_K_M
Speed (est.)
~59 tok/s
Runs well

Unified memory

Ryzen AI Max+ 395

128GB unified · ~$3,300

Quant
Q8_0
Speed (est.)
~5.8 tok/s
Runs well

Speeds are estimates at the quantization shown with 8K context. We may earn a commission when you buy through these links. Learn more.

Memory

Gemma 4 31B VRAM requirements by quantization

Lower-bit quantizations shrink the model at some cost to quality. Q4_K_M is the usual sweet spot. Totals include the KV cache for the context length shown plus runtime overhead.

Memory needed for Gemma 4 31B at each quantization level
QuantizationQualityWeightsTotal @ 8K ctxTotal @ 32K ctx
Q2_KRough12 GB15 GB17 GB
Q3_K_MUsable16 GB19 GB21 GB
Q4_K_MRecommendedDefault20 GB22 GB24 GB
Q5_K_MVery good23 GB26 GB28 GB
Q6_KNear-lossless27 GB30 GB32 GB
Q8_0Practically lossless33 GB36 GB38 GB
BF16Full precision61 GB66 GB68 GB

KV cache note: 60 layers: 50 sliding-window layers (1,024-token window, 16 KV heads x 256 dims) and 10 global layers (4 KV heads x 512 dims). Only the global layers grow with context: 2 x 10 x 4 x 512 x 2 bytes = 81,920 bytes per token, about 21GB at the full 256K. The sliding layers add a fixed buffer of about 0.8GB to 1.3GB depending on batch size.

Performance

How fast Gemma 4 31B runs

All GPUs

Single-user generation speed at 8K context on popular GPUs that fit the model entirely in memory, at the best quantization each can hold. Measured values require the exact hardware, model, and quantization at that context; other rows use estimates.

  1. RTX 5090

    Q5_K_M · 32GB · 8K context

    ~59tok/s

  2. RTX PRO 6000

    Q8_0 · 96GB · 8K context

    ~42tok/s

  3. RTX 4090

    Q4_K_M · 24GB · 8K context

    ~40tok/s

  4. RTX 3090

    Q4_K_M · 24GB · 8K context

    ~33tok/s

  5. RTX PRO 5000 72GB

    Q8_0 · 72GB · 8K context

    ~32tok/s

  6. RX 7900 XTX

    Q4_K_M · 24GB · 8K context

    ~30tok/s

  7. V100 32GB

    Q5_K_M · 32GB · 8K context

    ~25tok/s

  8. RTX 6000 Ada

    Q8_0 · 48GB · 8K context

    ~23tok/s

  9. M5 Ultra 512GB

    Q8_0 · 512GB · 8K context

    ~20tok/s

  10. M5 Ultra 256GB

    Q8_0 · 256GB · 8K context

    ~20tok/s

Estimated (method)

Measured

Gemma 4 31B benchmarks

Benchmark database
  • 2× RX 7900 XTXGemma 4 31B · Q8_0 · llama.cpp · ROCm (HIP) · pp512 / tg128 · Context depth not reported · Build: Various builds; the commit is listed in each result
    Source notes

    Same two-card setup with tensor split (-sm tensor) and flash attention on. Same comment (discussioncomment-18122692).

    Scoreboard read on 2026-10-14. Scoreboard rows are llama-bench on Llama 2 7B Q4_0 (3.56 GiB) with all layers on the GPU, pp512 and tg128. genTps is the flash-attention-off tg128 column; the flash-attention-on figure is in each result's notes. Newer results from user comments are added at the end, each with its own link.

    32 tok/s llama.cpp discussion #15021: Performance of llama.cpp on AMD ROCm (HIP)
  • 2× RX 7900 XTXGemma 4 31B · Q8_0 · llama.cpp · Vulkan · pp512 / tg128 · Context depth not reported · Build: Various builds; the commit is listed in each result
    Source notes

    Two RX 7900 XTX on PCIe 4.0 x8, default layer split, flash attention on, build b10590. Cards were overclocked (core up to 3000 MHz, VRAM 2650 MHz, 350 W). Gemma 4 31B Q8_0 is 30.38 GiB. Tensor split gave 21.03 t/s. Posted by Danik-droid: https://github.com/ggml-org/llama.cpp/discussions/10879#discussioncomment-18122886 (2026-08-23).

    Scoreboard maintained by netrunnereve, read on 2026-10-14. Scoreboard rows are llama-bench on Llama 2 7B Q4_0 (3.56 GiB) with all layers on the GPU, pp512 and tg128. genTps is the flash-attention-off tg128 column; the flash-attention-on figure is in each result's notes. A few extra results from user comments are added at the end, each with its own link.

    24 tok/s llama.cpp discussion #10879: Performance of llama.cpp with Vulkan
  • 2× RX 7900 XTXGemma 4 31B · Q8_0 · llama.cpp · ROCm (HIP) · pp512 / tg128 · Context depth not reported · Build: Various builds; the commit is listed in each result
    Source notes

    Two RX 7900 XTX on PCIe 4.0 x8, default layer split, flash attention off, build b10590. Cards were overclocked (core up to 3000 MHz, VRAM 2650 MHz, 350 W). Gemma 4 31B Q8_0 is 30.38 GiB. Flash attention on: 23.43 t/s. Posted by Danik-droid: https://github.com/ggml-org/llama.cpp/discussions/15021#discussioncomment-18122692 (2026-08-23).

    Scoreboard read on 2026-10-14. Scoreboard rows are llama-bench on Llama 2 7B Q4_0 (3.56 GiB) with all layers on the GPU, pp512 and tg128. genTps is the flash-attention-off tg128 column; the flash-attention-on figure is in each result's notes. Newer results from user comments are added at the end, each with its own link.

    23 tok/s llama.cpp discussion #15021: Performance of llama.cpp on AMD ROCm (HIP)

Overview

About Gemma 4 31B

Gemma 4 31B is Google's flagship open model, a dense 31B with image input, a 256K context, a thinking mode, and an Apache 2.0 license. It is the strongest Gemma yet and a well-rounded choice for writing, multilingual chat, vision, and coding, though Qwen3.8 27B scores higher on reasoning and agentic benchmarks. At Q4_K_M it needs about 21.5GB with 8K context plus a fixed buffer of about 1GB for its sliding-window layers, which fits a 24GB GPU with a modest context; a 32GB RTX 5090 or a Mac with 36GB or more is more comfortable. As a dense model it is slower than Gemma 4 26B A4B on the same hardware.

Strengths

  • +Excellent writing, multilingual chat, and image understanding
  • +Thinking mode and 256K context
  • +Compact long-context KV cache for a dense 31B model
  • +Apache 2.0 license

Weaknesses

  • −Tight on 24GB GPUs at Q4_K_M once context grows
  • −Slower than mixture-of-experts models of similar quality
  • −Trails Qwen3.8 27B on reasoning and agentic coding benchmarks
ChatVisionReasoningCodingWritingMultilingualAgents & toolsImage inputToggleable reasoning

Setup

How to run Gemma 4 31B

Ollama
$ ollama run gemma4:31b
llama.cpp
$ llama-server -hf unsloth/gemma-4-31B-it-GGUF:Q4_K_M -c 8192 -ngl 99

Weights: google/gemma-4-31B-it · GGUF: unsloth/gemma-4-31B-it-GGUF

Alternatives

All models

Frequently asked questions

How much VRAM do you need to run Gemma 4 31B?

About 22GB at Q4_K_M with 8K tokens of context: 19.6GB of weights, 1.7GB of KV cache, and 1.2GB of runtime overhead. Higher-precision quants and longer contexts need more; see the table above.

What is the cheapest GPU that can run Gemma 4 31B?

The smallest card in our database that can hold it is the RTX 4000 Ada (20GB), at Q3_K_M with little memory to spare, generating ~18 tokens/sec.

Is Gemma 4 31B free for commercial use?

Gemma 4 31B is released under the Apache 2.0 license. That is a permissive license, so commercial use is allowed.

How long a context does Gemma 4 31B support?

Up to 262,144 tokens (256K). Long contexts need a lot of extra memory for the KV cache, so most local setups run 8K to 32K.

Sources: Gemma 4 31B IT model card (Hugging Face), Artificial Analysis: Gemma 4 31B vs Qwen3.5 9B, Ollama gemma4 library. Capability score basis: Artificial Analysis Intelligence Index v4: 39 in reasoning mode (April 2026), mapped onto the Llama Builds scale above gpt-oss-120b.