Run Gemma 4 Locally
Gemma 4 runs on your own computer or phone: free, private and offline once downloaded. This page shows what hardware you need, the three steps to get chatting, and how to add EmbeddingGemma 2 for private search over your own files.
Windows, macOS, Linux, Android and iOS ·
What you gain by running it yourself
Private
Your prompts, files and answers stay on your machine. Nothing is sent to a provider.
Offline
Once the model is downloaded it needs no internet connection.
No usage fees
The models are free under Apache 2.0. You pay only for hardware and electricity.
Yours to control
Pick the size, the settings and when to update. You can also fine-tune it.
The trade-off: a hosted service is simpler and can run larger models than your hardware allows. See pricing for hosted costs and limitations for what the models cannot do.
Hardware for each size
Memory is what matters most: the graphics card's memory on a PC, or total memory on an Apple silicon Mac.
| Model | Memory, 4-bit | Ollama download | Context | Accepts | A sensible fit |
|---|---|---|---|---|---|
| Gemma 4 E2B | 2.9 GB | 4.3 GB | 128K | Text, image, audio | An 8 GB laptop; most phones |
| Gemma 4 E4B | 4.5 GB | 6.1 GB | 128K | Text, image, audio | 8 to 12 GB machines; flagship phones |
| Gemma 4 12B | 6.7 GB | 7.2 GB | 256K | Text, image, audio | A 12 to 16 GB graphics card or 16 GB Mac |
| Gemma 4 26B A4B | 14.4 GB | 16 GB | 256K | Text, image | A 24 GB graphics card or 32 GB Mac |
| Gemma 4 31B | 17.5 GB | 19 GB | 256K | Text, image | A 24 to 32 GB graphics card or 32 GB+ Mac |
Memory figures are from Google's Gemma 4 model card and cover the model only; conversations need more on top. Downloads are the QAT builds on Ollama's tag list. Every size can also read video as a series of frames. Ollama lists its builds as taking text and images, so for audio use another app. "A sensible fit" is this site's guidance; the VRAM guide goes deeper and the QAT page explains the small builds.
What can my machine run?
Choose your device and memory for a suggested model.
This site's rule of thumb: the largest model whose download is under about 70% of your memory. It is a starting point, not a guarantee. For more options use the runtime selector or compare models.
Three steps with Ollama
The shortest route on Windows, macOS and Linux.
Install Ollama
Download it from ollama.com and run the installer.
Run a model
Open a terminal and type
ollama run gemma4:12b-it-qat. The first run downloads 7.2 GB.Start chatting
Type your question at the prompt. Type
/byeto leave. From now on it works offline.
ollama run gemma4:12b-it-qat # download (7.2 GB) and chat ollama run gemma4:12b-it-qat "What is in this image? ./photo.png" ollama list # models you have ollama ps # what is loaded now ollama rm gemma4:12b-it-qat # delete to free disk
/set parameter num_ctx 32768 # longer memory for this chat /set think # reason before answering /set nothink # answer straight away /clear # forget the conversation so far /bye # leave
Less memory? Use gemma4:e4b-it-qat or gemma4:e2b-it-qat. The full walkthrough is on the Ollama page and in the install guide.
Choose the app that suits you
| App | Best for | Runs on | Guide |
|---|---|---|---|
| Ollama | The quickest start; a local API for your own programs | Windows, macOS, Linux | Ollama |
| LM Studio | A desktop app with a chat window and no terminal | Windows, macOS, Linux | LM Studio |
| llama.cpp | Fine control, and Google's GGUF files directly | Windows, macOS, Linux | Install guide |
| MLX | Apple silicon Macs, especially if you work in Python | macOS | Mac setup |
| Transformers | Python projects, research and fine-tuning | Any system with Python | How to use |
| Google AI Edge Gallery | Phones and tablets | Android, iOS | Mobile downloads |
lms get google/gemma-4-12b-qat # download lms load google/gemma-4-12b-qat # load into memory lms server start # start the local API on port 1234
# install llama.cpp (macOS or Linux), then serve with a web page
curl -LsSf https://llama.app/install.sh | sh
llama serve -hf google/gemma-4-12B-it-qat-q4_0-gguf:Q4_0pip install mlx mlx-lm mlx-vlm
mlx_lm.generate --model mlx-community/gemma-4-e2b-it-4bit --prompt "Who are you?"
# a local server that also accepts images
mlx_vlm.server --model mlx-community/gemma-4-e2b-it-4bitfrom transformers import AutoProcessor, AutoModelForMultimodalLM
processor = AutoProcessor.from_pretrained("google/gemma-4-12B-it")
model = AutoModelForMultimodalLM.from_pretrained(
"google/gemma-4-12B-it", device_map="auto")llama.cpp and Transformers commands are from Google's model cards; MLX commands from Google's MLX guide; LM Studio names from its catalogue. "Best for" is this site's guidance. Where to get the files is on the download hub and in how to download.
Use your local model from your own code
Ollama and LM Studio both start a small server on your machine. Programs talk to it the same way they would talk to a hosted service.
# pip install ollama
import ollama
reply = ollama.chat(
model="gemma4:12b-it-qat",
messages=[{"role": "user", "content": "Why is the sky blue?"}],
)
print(reply["message"]["content"])curl http://localhost:11434/api/chat -d '{
"model": "gemma4:12b-it-qat",
"messages": [
{"role": "user", "content": "Why is the sky blue?"}
],
"think": false,
"stream": false
}'# pip install openai from openai import OpenAI # Ollama: port 11434. LM Studio: http://localhost:1234/v1 client = OpenAI(base_url="http://localhost:11434/v1", api_key="ollama") reply = client.chat.completions.create( model="gemma4:12b-it-qat", messages=[{"role": "user", "content": "Why is the sky blue?"}], ) print(reply.choices[0].message.content)
- Ollama listens at
http://localhost:11434. - LM Studio listens at
http://localhost:1234/v1once you start its server. - Existing tools work. Anything that accepts an OpenAI-style address can be pointed at your machine.
- Thinking is a switch. Set
"think"to true or false in Ollama's API. See the prompt guide. - Try it in the browser. The playground on this site connects to your local Ollama.
More examples, including images and tools, are on the API page and the coding page. To serve other people from your own hardware, see self-hosting.
Running it on a phone
The two edge models, E2B and E4B, are built for phones. Google's free AI Edge Gallery app downloads and runs them.
What to expect
E2B is a 2.58 GB download, E4B 3.66 GB. Phone builds remember up to 32K tokens of conversation.
Google reports E2B at 52.1 tokens a second on a Galaxy S26 Ultra and 56.5 on an iPhone 17 Pro, using the graphics chip. Step-by-step setup is on the Android page.
Run EmbeddingGemma 2 locally too
EmbeddingGemma 2 is Google's small, free model for search. It turns your text, code, images, audio and video into numbers that can be compared, so you can find things by meaning. Run it beside Gemma 4 and you can ask questions about your own files without anything leaving your machine.
On Ollama. Text and images.
The 270m name on Ollama.
Memory in use on a Pixel 11 Pro, per Google.
Small enough for an ordinary laptop.
ollama pull embeddinggemma-2 # full model, 1.3 GB
ollama pull embeddinggemma-2:270m # text and code only, 378 MB
curl http://localhost:11434/api/embed -d '{
"model": "embeddinggemma-2",
"input": "What causes the northern lights?"
}'# pip install -U "sentence-transformers[image,audio,video]" transformers
from sentence_transformers import SentenceTransformer
model = SentenceTransformer("google/embeddinggemma-2")
query_emb = model.encode("ocean waves at sunset", prompt_name="SearchQuery")
doc_emb = model.encode("Photos from the beach trip", prompt_name="Document")
image_emb = model.encode({"image": "sunset_beach.jpg"})# private question answering: both models on your machine
import ollama
from sentence_transformers import SentenceTransformer
embedder = SentenceTransformer("google/embeddinggemma-2")
passages = ["...your documents, split into passages..."]
passage_embs = embedder.encode(passages, prompt_name="Document")
question = "What did the contract say about renewal?"
q_emb = embedder.encode(question, prompt_name="QuestionAnswering")
best = passages[embedder.similarity(q_emb, passage_embs).argmax()]
reply = ollama.chat(model="gemma4:12b-it-qat", messages=[
{"role": "user", "content": f"Answer from this passage only:\n{best}\n\nQuestion: {question}"}])
print(reply["message"]["content"])- Ollama is the quickest route for text. It lists text and image input only.
- Use Python for audio and video. The sentence-transformers library handles every input type.
- Use the right task prompt. Questions and stored text get different ones; see the prompt guide.
- Do not use float16. Google warns the model's values exceed its range; use bfloat16 or float32.
- Plan your disk space. About 1.5 GB for every million full-length vectors.
Ollama names and sizes from Ollama's library; Python usage from Google's developer guide and the model card. The "search + answer" example is this site's sketch combining the two; it has not been run against your data, so treat it as a starting point.
Common problems
This site's guidance on what to check first.
| What you see | Likely cause | Try this |
|---|---|---|
| Very slow replies | The model does not fit in graphics memory and is running on the processor | Run ollama ps to check; choose a smaller size |
| Out-of-memory error | Model plus conversation is larger than your memory | Pick a smaller size or a shorter context |
| Forgets earlier messages | The app's context setting is smaller than the chat | Raise it, for example /set parameter num_ctx 32768 |
| Slow on easy questions | Thinking is on | /set nothink |
| Audio is ignored | The size or app does not accept audio | Use E2B, E4B or 12B in an app that supports audio |
| Disk filling up | Several large models downloaded | ollama list, then ollama rm the ones you do not use |
More help is in the FAQ; what each model can and cannot do is under capabilities and features.
Local running questions
Can I run Gemma 4 on my own computer?
Yes. The smallest size needs about 2.9 GB of memory at 4-bit and the largest about 17.5 GB. Most laptops made in the last few years can run at least E2B or E4B.
Is it free?
Yes. Gemma 4 and EmbeddingGemma 2 are Apache 2.0, and the apps on this page are free to download.
Do I need a graphics card?
No, but it helps a lot. Without one, the model runs on the processor and larger sizes are slow. Apple silicon Macs use their shared memory.
Does it work offline?
Yes, after the first download. Nothing is sent anywhere while you chat.
Which size should I run?
The largest that fits your memory with room to spare. For many machines that is the 12B; see the 12B page and all variants.
How good is it compared with hosted assistants?
Strong for a model you can run yourself, but not as strong as the largest hosted models. See the benchmarks and Gemma 4 vs Claude Code.
Can I run EmbeddingGemma 2 on the same machine?
Yes. It is small, between 378 MB and 1.3 GB on Ollama, and runs alongside Gemma 4.
Is running locally safe?
Your data stays with you, but you are responsible for how the model is used and for keeping it up to date. See safety.
Your own AI, on your own machine
Free, private and offline. One command to start.