Black Friday: 10% off every GPU you launch, no code needed. Until 30 Nov. Rent a GPU

Arrakis / Blog / Run open models

Gemma 4 31B Self Host: One GPU, One API Call

A Gemma 4 31B self host setup is one GPU and one API call. The model needs about 75 GB of GPU memory in 16-bit, so a single 80 GB A100 or H100 runs it at full precision, and about 19 GB in 4-bit, which fits a 24 GB RTX 4090. Rent that card by the hour and you get your own OpenAI-compatible endpoint, its own API key and root SSH.

What self-hosting gets you

  • Your endpoint. A URL that speaks the OpenAI API, behind a key made for it. The GPUs are yours for the rental: a machine never reaches another renter's.
  • Your settings. Paste your own engine options: context length, prefix caching, anything vLLM or SGLang takes. Change them later over SSH without a new machine.
  • Your bill shape. One hourly price, nothing per token. A busy hour costs the same as a quiet one, which is also the warning: an idle endpoint still bills.
  • A licence that lets you. google/gemma-4-31B-it is listed under Apache 2.0 and is not gated, so no Hugging Face token is needed.

Pick the GPU

Precision GPU memory One GPU that holds it Price per hour now
16-bit 75 GB A100 80 GB or H100 (80 GB) the live price (A100), the live price (H100)
8-bit 38 GB L40S or RTX A6000 (48 GB) the live price (L40S), the live price (RTX A6000)
4-bit 19 GB RTX 4090 (24 GB) the live price

The figures come from the Gemma 4 31B model page, on the rules in the GPU memory guide: about 2.4 bytes per parameter in 16-bit, 1.2 in 8-bit, 0.6 in 4-bit, with 20% included for the KV cache at moderate context.

Gemma 4 31B is a dense model with 31.3B parameters. It reads images as well as text, and its context window is 262,144 tokens. The weights alone take about 63 GB in 16-bit, 31 GB in 8-bit and 16 GB in 4-bit. Whatever the card has left is room for the KV cache:

  • about 17 GB on an 80 GB A100 in 16-bit,
  • about 17 GB on a 48 GB L40S in 8-bit,
  • about 8 GB on a 24 GB RTX 4090 in 4-bit.

The 20% headroom covers moderate context, not the full window, so cap the context at what your app really sends. Need much more room for long prompts and many users? Put the 8-bit model on an 80 GB card: about 49 GB left over. The price column tells you what each choice costs per hour.

Self-host it, step by step

1. Make a token. In the console, open API & agents and create one, and save an SSH key while you are there.

2. Plan it. POST /v1/deploy/plan with the model is free and rents nothing. It lists every GPU the model fits on now, best value first, each with its hourly price.

3. Deploy it with a removal time and the engine options you want:

Shell
curl -X POST https://arrakis.goodailabs.com/v1/deploy \
  -H "Authorization: Bearer ark_..." \
  -H "Content-Type: application/json" \
  -d '{"model": "google/gemma-4-31B-it", "engine": "vllm",
       "termination_hours": 8,
       "extra_args": "--max-model-len 32768 --enable-prefix-caching"}'

Without a node_id, Arrakis rents the best-ranked machine that holds the model, on as few GPUs as it allows. Your options reach the engine word for word, without a shell.

4. Wait for ready. The engine downloads the model, then loads it. GET /v1/instances/{id}/endpoint returns the address and key, and ready: true once the model answers. If it does not, GET /v1/instances/{id}/endpoint/log shows the end of the engine's log.

5. Call it from any OpenAI client:

Python
from openai import OpenAI

client = OpenAI(base_url="http://<endpoint>/v1", api_key="sk-...")
reply = client.chat.completions.create(
    model="google/gemma-4-31B-it",
    messages=[{"role": "user", "content": "Draft a polite payment reminder."}],
)
print(reply.choices[0].message.content)

For the 4-bit setup on an RTX 4090, deploy a GGUF build on llama.cpp instead: {"model": "unsloth/gemma-4-31B-it-GGUF:Q4_K_M", "engine": "llamacpp", "termination_hours": 8}. Every option is on the deploy page, and once you have made the token, an agent can run steps 2 to 5 with plan_deploy and deploy_model (Arrakis for agents).

Keep it private, and know the limit

The endpoint is the machine's address over plain HTTP, with a gate that checks the key before a request reaches the engine, which listens only inside the machine. For traffic you would rather keep off the open internet, open an SSH tunnel and call http://localhost:8000/v1:

Shell
ssh root@<host> -p <port> -N -L 8000:localhost:8000

The honest limit: machines run on independent hosts, and a host can read what runs on its machine. Self-hosting gives you your own endpoint, your own key and your own settings. It is not a home for regulated or confidential data. More in private LLM deployment.

The MoE sibling: Gemma 4 26B A4B

gemma-4-26B-A4B-it has 25.8B parameters with 4B active for each token. It needs about 62 GB in 16-bit (one A100 80 GB), 31 GB in 8-bit (one 32 GB RTX 5090) and 15 GB in 4-bit (one RTX 4090). Same Apache 2.0 licence, same deploy call with its own name. Every expert still sits in memory, so the memory follows the 25.8B; the work for each token follows the 4B. More models that fit one card: open models on a single GPU.

Fine-tune it on the same class of card

Before activations: QLoRA about 22 GB (one RTX 4090), LoRA about 75 GB (one A100 80 GB), full fine-tuning about 500 GB (two B300s). Merge the adapter, push the model to a private Hugging Face repository, and deploy it with the same call plus a read-only hf_token.

Stop paying for idle

Set termination_hours to the hours you need. The machine is removed on time and billing stops with it. The schedule is the biggest lever on the bill:

Each fresh deploy downloads the model again on the machine's clock, so a daily schedule pays for a few minutes of loading every morning. That is still far less than the 14 idle hours a night an always-on endpoint bills for a team that sleeps.

Self-host Gemma 4 31B today

One GPU, one call, your own endpoint. Start in the console.

New here? Use code FIRST25 for $25 off your first deposit of $50 or more, until 31 December 2026.

Rent the GPUs in this post

New here? Use code FIRST25 for $25 off your first deposit of $50 or more, until 31 December 2026.

Lowest price now, per GPU-hour. Billed per started hour; stop any time.

Questions

What GPU do I need to self host Gemma 4 31B?
One GPU: an 80 GB A100 or H100 in 16-bit (about 75 GB), a 48 GB L40S or RTX A6000 in 8-bit (about 38 GB), or a 24 GB RTX 4090 in 4-bit (about 19 GB).
Is Gemma 4 31B licensed for commercial use?
google/gemma-4-31B-it is listed under Apache 2.0 on Hugging Face. Read the model card for the full terms.
Do I need a Hugging Face token to deploy Gemma 4 31B?
Not for google/gemma-4-31B-it: it is not gated. Gated or private models need a read-only token, which goes to the machine only and is never stored by Arrakis.
How is a self-hosted Gemma endpoint billed?
By the hour of the GPU, not per token. Each started hour is charged in full at the price locked when you rented, and billing stops when the machine is removed.
Can I fine-tune Gemma 4 31B on one GPU?
With QLoRA, on one RTX 4090 (about 22 GB before activations); with LoRA, on one 80 GB A100 or H100 (about 75 GB). Full fine-tuning needs about 500 GB, two B300s.

More from the blog

Every postRSS feed