Operationrange Get a free plan

How to run Gemma 4 on a cloud GPU

Google's Gemma 4 family comes in three sizes that matter for servers: the dense 31B, the 26B-A4B mixture-of-experts model (about 4B parameters active per token) and the 12B. All are Apache-2.0, multimodal and support a 256K context, and Google publishes official 4-bit quantization-aware (QAT) checkpoints. Here is how much memory each version needs, the cheapest GPU for it today, and how to serve it.

12B, 4-bit QAT
10.3 GBany 24 GB GPU
26B-A4B, 4-bit
14.4 GB24 GB with llama.cpp
31B, 4-bit QAT
23.3 GB32–48 GB with vLLM
31B, BF16
62.5 GB80 GB GPU
Which GPU

Gemma 4 GPU requirements

Most Gemma 4 layers use a 1,024-token sliding window, so their cache stops growing after 1K tokens; only the global layers keep a full-length cache: at most 84 MB per 1K tokens for the 31B, 21 MB for the 26B-A4B and 17 MB for the 12B.

Model · formatWeightsRuns on one GPU (32K+ context)Cheapest todayContext room on it
Gemma 4 31B
BF16 · vLLM
62.5 GBA100 80GB, RTX PRO 6000, H100, H200, B200A100 80GB · $0.84/hr≈153K tokens
Gemma 4 31B
FP8 · vLLM
33.3 GBRTX A6000, RTX 6000 Ada, L40S, A100 80GB, RTX PRO 6000 and moreRTX A6000 · $0.48/hr≈133K tokens
Gemma 4 31B
4-bit QAT (W4A16) · vLLM
23.3 GBRTX A6000, RTX 5090, RTX 6000 Ada, L40S, A100 80GB and moreRTX A6000 · $0.48/hr≈252K tokens
Gemma 4 31B
GGUF Q4_0 (QAT) · llama.cpp
17.7 GBRTX 3090, RTX 4090, RTX A6000, RTX 5090, RTX 6000 Ada and moreRTX 3090 · $0.22/hr≈66K tokens
Gemma 4 26B-A4B
BF16 · vLLM
51.6 GBA100 80GB, RTX PRO 6000, H100, H200, B200A100 80GB · $0.84/hrfull 256K context
Gemma 4 26B-A4B
GGUF Q4_0 (QAT) · llama.cpp
14.4 GBRTX 3090, RTX 4090, RTX A6000, RTX 5090, RTX 6000 Ada and moreRTX 3090 · $0.22/hrfull 256K context
Gemma 4 12B
BF16 · vLLM
23.9 GBRTX A6000, RTX 5090, RTX 6000 Ada, L40S, A100 80GB and moreRTX A6000 · $0.48/hrfull 256K context
Gemma 4 12B
4-bit QAT (W4A16) · vLLM
10.3 GBRTX 3090, RTX 4090, RTX A6000, RTX 5090, RTX 6000 Ada and moreRTX 3090 · $0.22/hrfull 256K context

Weights: file sizes on Hugging Face (google/gemma-4-*-it, Google's QAT w4a16 and Q4_0 GGUF releases, RedHatAI/gemma-4-31B-it-FP8-dynamic). Context room is calculated for one request with BF16 KV cache and is conservative, because Gemma 4 shares keys and values on some layers; see how we calculate VRAM. Prices: typical hourly price on the Vast.ai marketplace on 5 Dec 2026.

Pick a setup

Which Gemma 4 for which GPU

24 GB (RTX 3090, RTX 4090)

  • 12B, vLLMQAT 4-bit, 10.3 GB, full 256K context
  • 26B-A4B, llama.cppQ4_0 GGUF, 14.4 GB, full 256K context
  • 31B, llama.cppQ4_0 GGUF, 17.7 GB, ≈66K tokens

32–48 GB (RTX 5090, L40S, RTX 6000 Ada)

  • 31B QAT, RTX 5090≈66K tokens · $0.67/hr
  • 31B QAT, 48 GB≈217K tokens on an L40S · $0.73/hr
  • 31B FP8, 48 GB≈98K tokens on an L40S

80 GB (A100, H100)

  • 26B-A4B BF16One GPU, as in vLLM's recipe · full 256K context
  • 31B BF16Fits on one 80 GB GPU by our estimate (≈149K tokens on an H100); vLLM's recipe uses two GPUs with a 32K context for headroom.

Which size to choose

The 26B-A4B activates only about 4B parameters per token, so it generates fast and is cheap to serve; the dense 31B is the strongest of the three. The 12B is the budget option for simple chat, extraction and classification.

Step by step

Serve Gemma 4 with vLLM

The vLLM recipe requires vLLM 0.19.1 or newer and uses the image vllm/vllm-openai:latest. On Vast.ai, set the instance image to it, give it at least 100 GB of disk for the 31B BF16 weights and expose port 8000.

26B-A4B on one 80 GB GPU (recipe)

vllm serve google/gemma-4-26B-A4B-it \
  --max-model-len 32768

31B BF16 on two 80 GB GPUs (recipe)

vllm serve google/gemma-4-31B-it \
  --tensor-parallel-size 2 \
  --max-model-len 32768

Quantized 31B on one GPU

For FP8 and other quantized checkpoints, the recipe says to pass the repository to vllm serve directly:

vllm serve RedHatAI/gemma-4-31B-it-FP8-dynamic \
  --max-model-len 32768

Google's QAT checkpoint google/gemma-4-31B-it-qat-w4a16-ct is published in the compressed-tensors format that vLLM loads the same way. NVFP4 checkpoints (such as nvidia/gemma-4-31B-it-NVFP4) need Blackwell GPUs.

Useful flags (from the recipe)

  • Tool calling and thinking: --enable-auto-tool-choice --tool-call-parser gemma4 --reasoning-parser gemma4, plus the chat template examples/tool_chat_template_gemma4.jinja from the vLLM repository.
  • Text only: --limit-mm-per-prompt '{"image": 0, "audio": 0}' skips memory reserved for images and audio.
  • FP8 KV cache: --kv-cache-dtype fp8 saves about 50% of KV memory.
  • Throughput: --async-scheduling improves throughput; leave --gpu-memory-utilization at its default unless the GPU is shared.
24 GB GPUs

Run Gemma 4 with llama.cpp

Google publishes QAT Q4_0 GGUF files for llama.cpp (17.7 GB for the 31B, 14.4 GB for the 26B-A4B, 7.0 GB for the 12B). llama.cpp downloads them with -hf (see the llama.cpp README):

llama serve -hf google/gemma-4-26B-A4B-it-qat-q4_0-gguf --ctx-size 32768

In Docker, use ghcr.io/ggml-org/llama.cpp:server-cuda. llama.cpp is ideal for a single user or development; for many concurrent users, use vLLM on a GPU with more memory.

Cost

What Gemma 4 costs to run 24/7

  • 12B or 26B-A4B (4-bit) on RTX 4090≈ $341/month
  • 31B QAT on RTX 5090≈ $487/month
  • 31B FP8 on L40S≈ $536/month
  • 26B-A4B BF16 on H100≈ $1,705/month

Typical hourly price × 730 hours, marketplace prices on 5 Dec 2026.

Need Gemma 4 in production?

We deploy Gemma 4 behind an authenticated OpenAI-compatible API, with image input, tool calling, autoscaling, monitoring and 24/7 support. You pay the GPU provider directly, with no markup.

Have us set it up

How much VRAM other models need →

FAQ

Gemma 4 questions

How much VRAM does Gemma 4 31B need?

62.5 GB in BF16, 33.3 GB in FP8, 23.3 GB as Google's 4-bit QAT checkpoint for vLLM and 17.7 GB as the QAT Q4_0 GGUF, plus the KV cache for your context. The cheapest GPU with room for 32K tokens on 5 Dec 2026 is RTX A6000 · $0.48/hr with the QAT weights.

Can Gemma 4 run on an RTX 4090?

Yes. The 12B in 4-bit QAT runs in vLLM with full 256K context, the 26B-A4B as a Q4_0 GGUF in llama.cpp with full 256K context, and the 31B as a Q4_0 GGUF with ≈66K tokens.

Gemma 4 26B-A4B or 31B: which should I run?

The 26B-A4B is a mixture-of-experts model with about 4B active parameters per token, so it answers faster and serves more users per GPU. The dense 31B is the stronger model. Try both on your own prompts; on an 80 GB GPU both fit in BF16.

What are Gemma 4 QAT checkpoints?

Quantization-aware training (QAT) checkpoints are trained to work in 4-bit, so they lose less quality than quantizing a finished model. Google publishes them as w4a16 (compressed-tensors, for vLLM) and Q4_0 GGUF (for llama.cpp).

Is Gemma 4 free for commercial use?

The Gemma 4 models on Hugging Face are published under the Apache-2.0 license. Check the license on the model card before you deploy.