Guideschevron_rightServers

Servers · 8 min read · Updated

How to Run Gemma 4 on Your Own Server

The quickest way to run Gemma 4 is ollama run gemma4:26b, or gemma4:e4b on a small server. At 4-bit, Google lists about 2.9 GB of memory for E2B, 4.5 GB for E4B, 6.7 GB for 12B, 14.4 GB for 26B A4B and 17.5 GB for 31B, before the context. The two small ones run on an ordinary server; for 26B and 31B use a GPU with 24 GB or more.

Gemma 4 Sizes and Memory

Gemma 4 models and the memory each needs
ModelParametersContext4-bit8-bit16-bitOllama downloadAudio input
Gemma 4 E2B2.3B effective128K2.9 GB5.7 GB11.4 GB4.6–7.5 GBYes
Gemma 4 E4B4.5B effective128K4.5 GB8.9 GB17.9 GB6.6–9.5 GBYes
Gemma 4 12B11.95B256K6.7 GB13.4 GB26.7 GB7.7–8.0 GBYes
Gemma 4 26B A4B25.2B (3.8B active)256K14.4 GB28.8 GB57.7 GB16–19 GBNo
Gemma 4 31B30.7B256K17.5 GB34.9 GB69.9 GB19–20 GBNo

From Google's Gemma 4 overview, model card and Ollama's library. Google's memory figures cover the weights only: context and software come on top. Every size takes text and images.

Gemma 4 on Our GPU Servers

The largest Gemma 4 that fits each server's total GPU memory, with 4 GB left for the context and engine. A server with several cards splits the model across them; see running an LLM on multiple GPUs.

GPU servers and the largest Gemma 4 each holds
PlanGPUTotal GPU memorySystem memoryLargest Gemma 4Price
Intel Core Ultra 9 285K w/ NVIDIA Tesla P4NVIDIA Tesla P4 · 8 GB8 GB192 GBE2B at 4-bit$589.00/mo
NVIDIA DGX SparkNVIDIA DGX Spark · 128 GB128 GB128 GB31B at 8-bit$609.00/mo
AMD EPYC 7443P w/ NVIDIA RTX 3090NVIDIA RTX 3090 · 24 GB24 GB256 GB31B at 4-bit, 12B at 8-bit$659.00/mo
AMD Ryzen 9 9950X w/ NVIDIA RTX 3050NVIDIA RTX 3050 · 6 GB6 GB192 GBPartly on the CPU$699.00/mo
AMD Dual EPYC 7702 w/ NVIDIA RTX 3050NVIDIA RTX 3050 · 6 GB6 GB256 GBPartly on the CPU$749.00/mo
AMD Ryzen 9 9950X w/ NVIDIA RTX 5090NVIDIA RTX 5090 · 32 GB32 GB64 GB31B at 4-bit, 12B at 8-bit$789.00/mo
AMD Ryzen 9 9950X w/ NVIDIA RTX 5090NVIDIA RTX 5090 · 32 GB32 GB96 GB31B at 4-bit, 12B at 8-bit$829.00/mo
AMD Dual EPYC 7702 w/ NVIDIA RTX 5070NVIDIA RTX 5070 · 12 GB12 GB256 GB12B at 4-bit, E2B at 8-bit$859.00/mo
AMD EPYC 7702 w/ 4x NVIDIA RTX 30904× NVIDIA RTX 3090 · 24 GB each96 GB128 GB31B at 8-bit$929.00/mo
AMD EPYC 7443P w/ 4x NVIDIA V100 16GB4× NVIDIA V100 · 16 GB each64 GB128 GB31B at 8-bit$1,059.00/mo
AMD EPYC 7443P w/ 4x NVIDIA V100 32GB4× NVIDIA V100 · 32 GB each128 GB128 GB31B at 8-bit$1,059.00/mo
AMD EPYC 7443P w/ 4x NVIDIA V1004× NVIDIA V100—256 GB—$1,189.00/mo
Intel Dual Xeon Platinum 8260 w/ 8x NVIDIA V1008× NVIDIA V100 · 32 GB each256 GB1 TB31B at 8-bit$1,319.00/mo
2x NVIDIA DGX Spark2× NVIDIA DGX Spark · 128 GB each256 GB256 GB31B at 8-bit$1,449.00/mo
AMD EPYC 9B14 w/ 2x NVIDIA RTX 50902× NVIDIA RTX 5090 · 32 GB each64 GB384 GB31B at 8-bit$2,639.00/mo
AMD EPYC 9355 w/ NVIDIA RTX PRO 6000NVIDIA RTX PRO 6000 · 96 GB96 GB768 GB31B at 8-bit$2,639.00/mo
AMD EPYC 9254 w/ 4x NVIDIA RTX 50904× NVIDIA RTX 5090 · 32 GB each128 GB384 GB31B at 8-bit$3,819.00/mo

Gemma 4 on a VPS

The smaller models run on the processor with no GPU: fine for classifying, summarising and short answers, slow for long ones. The table leaves 3 GB for the system and a short context, and shows the lowest-priced plan with enough memory. VPS processors are shared, so for constant use run it on a CPU server of your own.

VPS plans with enough memory for each Gemma 4 model at 4-bit
ModelWeights at 4-bitPlanMemoryPrice
Gemma 4 E2B2.9 GBBronze6 GB$37.50/mo
Gemma 4 E4B4.5 GBSilver8 GB$46.50/mo
Gemma 4 12B6.7 GBGold12 GB$60.00/mo
Gemma 4 26B A4B14.4 GBPlatinum24 GB$100.00/mo
Gemma 4 31B17.5 GBPlatinum24 GB$100.00/mo

1. Run Gemma 4 With Ollama

curl -fsSL https://ollama.com/install.sh | sh
ollama run gemma4:e4b        # small servers (also the default, gemma4)
ollama run gemma4:26b        # fast for its size
ollama run gemma4:31b        # the largest

Ollama's context is 4,096 tokens unless you raise it. Run sudo systemctl edit ollama.service, add the lines below, then sudo systemctl daemon-reload && sudo systemctl restart ollama. A longer context takes more memory.

[Service]
Environment="OLLAMA_CONTEXT_LENGTH=32768"

The tags gemma4:cloud and similar run on Ollama's servers, not yours. Cannot connect? See fixing Ollama connection refused.

2. Run Gemma 4 With llama.cpp

curl -LsSf https://llama.app/install.sh | sh
openssl rand -hex 24 > ~/.llm-key

llama serve -hf ggml-org/gemma-4-26B-A4B-it-GGUF:Q4_0 \
  -c 32768 --host 127.0.0.1 --port 8080 --api-key "$(cat ~/.llm-key)" \
  --temp 1.0 --top-p 0.95 --top-k 64

The same repository name with E2B, E4B, 12B or 31B in it gives the other sizes. Google also publishes quantization-aware 4-bit builds, trained to lose less quality, such as gemma-4-31B-it-qat-q4_0-gguf. For the 26B A4B on a small GPU, --n-cpu-moe N keeps the experts of the first N layers in system memory.

3. Serve Gemma 4 With vLLM

For many users, vLLM. Google's quantization-aware build of the 31B for vLLM keeps the weights at 4-bit; vLLM's recipe needs version 0.19.1 or newer:

uv venv && source .venv/bin/activate
uv pip install -U vllm --torch-backend auto

vllm serve google/gemma-4-31B-it-qat-w4a16-ct \
  --max-model-len 16384 \
  --reasoning-parser gemma4 \
  --host 127.0.0.1 --api-key "$(cat ~/.llm-key)"
# OpenAI-compatible API on http://127.0.0.1:8000/v1

Raise --max-model-len as far as memory allows. With two cards add --tensor-parallel-size 2. For tool calls, the recipe adds --enable-auto-tool-choice --tool-call-parser gemma4 and a chat template from vLLM's repository. HTTPS in front is in serving an LLM API.

Thinking Mode and Settings

  • Sampling: Google recommends temperature=1.0, top_p=0.95, top_k=64.
  • Thinking: on when the system prompt starts with <|think|>, off without it. Most engines expose it as a setting.
  • Conversation history: keep only the final answers of earlier turns, not the model's thoughts.
  • A chat interface: Open WebUI works with Ollama, llama.cpp and vLLM alike.

Comparing models? See running Qwen4 and running gpt-oss.

Gemma, Google and NVIDIA are trademarks of their respective owners. Virteche is not affiliated with or endorsed by them. Details about their products come from their public documentation as of the date at the top of this guide.

Common Questions

  • How much VRAM does Gemma 4 31B need?

    Google lists about 17.5 GB at 4-bit, 34.9 GB at 8-bit and 69.9 GB at 16-bit for the weights alone. Add a few gigabytes for the context, so a 24 GB card is a sensible minimum at 4-bit.

  • Which Gemma 4 should I run on a CPU?

    The 26B A4B if you have the memory: it activates about 4 billion parameters per token, so it answers faster than its size suggests. On a small server, E2B or E4B. The 31B is dense and slow on a processor.

  • What does A4B mean in Gemma 4 26B A4B?

    About 4 billion active parameters. It is a mixture-of-experts model with 25.2 billion parameters in total, of which 3.8 billion are used per token. All of them still have to be loaded into memory.

  • Is Gemma 4 free for commercial use?

    The Gemma 4 weights are published under Apache 2.0, unlike earlier Gemma versions, which had Google's own terms of use. Check the licence on the card of the model you download.

Plans and prices

GPU Servers

GPU servers for Gemma 4 26B and 31B, with full root access.

See all plans
  • Intel Core Ultra 9 285K w/ NVIDIA Tesla P4

    NVIDIA Tesla P4 · 8 GB GPU

    24 Cores · 192 GB RAM · 2x 3.84TB NVMe Gen4

    Los Angeles, CA (LA1) · 50 TB transfer · 25 Gbps

    $589.00/mo

  • NVIDIA DGX Spark

    NVIDIA DGX Spark · 128 GB GPU

    20 Cores · 128 GB RAM · 4TB NVMe Gen4

    Ogden, UT (UT1) · 50 TB transfer · 10 Gbps

    $609.00/mo

    Sold out
  • AMD EPYC 7443P w/ NVIDIA RTX 3090

    NVIDIA RTX 3090 · 24 GB GPU

    24 Cores · 256 GB RAM · 3.84TB NVMe

    Ogden, UT (UT1) · 100 TB transfer · 10 Gbps

    $659.00/mo

  • AMD Ryzen 9 9950X w/ NVIDIA RTX 3050

    NVIDIA RTX 3050 · 6 GB GPU

    16 Cores · 192 GB RAM · 2x 2 TB NVMe

    Ashburn, VA (ASH1) · Dallas, TX (TX3) · New York, NY (NY2) · Charlotte, NC (NC1) · Bend, OR (OR1) · Unmetered transfer · 1 Gbps

    $699.00/mo

Keep Reading

All guides
How to Run Gemma 4 on Your Own Server | Virteche Cloud