A step-by-step guide to getting Google's powerful open-weights AI model running on your machine — no prior experience required.
Gemma 4 is Google DeepMind's latest open-weights language model, available free for personal and research use. It delivers state-of-the-art text generation, coding assistance, and question answering — all running locally on your own hardware, with no cloud subscription required.
The Free Version gives you access to the base model weights, letting you run inference, fine-tune, and experiment without usage limits or API costs. Whether you're a developer, student, or curious enthusiast, Gemma 4 is designed to be accessible and powerful.
Windows 10/11, macOS 12+, or any modern Linux distribution (Ubuntu 20.04+ recommended)
Minimum 8 GB RAM. 16 GB or more is strongly recommended for smooth performance.
At least 10 GB of free storage for the model weights and dependencies.
An NVIDIA GPU with 6 GB+ VRAM dramatically speeds up inference. CPU-only mode is supported.
Gemma 4's model weights are hosted on Hugging Face, the leading platform for open-source AI models. You'll need a free account to accept Google's usage licence and download the model files.
Head to huggingface.co and click "Sign Up" in the top-right corner. Fill in your name, email address, and choose a password. After verifying your email, your account will be ready in under two minutes.

Before downloading, you must accept Google's Gemma Terms of Use. Visit the official Gemma 4 model page on Hugging Face — search for "google/gemma-4" in the search bar. On the model page, you will see a licence agreement prompt. Read through the terms and click "Agree and access repository". Access is granted instantly and automatically.

Gemma 4 requires Python 3.9 or higher. Open your terminal (or Command Prompt on Windows) and check if Python is already installed by typing:
python --versionIf Python is not installed, download the latest stable release from python.org. Run the installer and make sure to tick "Add Python to PATH" during setup on Windows — this is a common step that's easy to miss.
It is best practice to install Gemma 4 inside a virtual environment — an isolated Python workspace that keeps its dependencies separate from the rest of your system. This prevents version conflicts and makes it easy to remove everything cleanly later.
Navigate to the folder where you want to store your Gemma project using the cd command.
Run python -m venv gemma-env to create a new virtual environment named gemma-env.
On Windows: gemma-env\Scripts\activate — On macOS/Linux: source gemma-env/bin/activate
Your terminal prompt should now show (gemma-env) at the start — you're inside the environment.
With your virtual environment active, you'll install the core Python libraries needed to load and run Gemma 4. These include Transformers (by Hugging Face), PyTorch, and a few supporting packages. Run the following command in your terminal:
pip install transformers torch accelerate bitsandbytesThis may take a few minutes depending on your internet speed. Once complete, all the necessary components will be installed and ready. If you have an NVIDIA GPU, also run:
pip install nvidia-cublas-cu12
To download gated models like Gemma 4, you need a personal access token from Hugging Face. This token proves your identity and confirms you've accepted the licence terms.
Log in to your Hugging Face account, click your profile picture in the top-right, then go to Settings → Access Tokens. Click "New token", give it a name (e.g. "gemma-install"), and select the Read role. Click "Generate" and copy the token — it looks like hf_xxxxxxxxxx.
Once you have your token, authenticate your terminal session by running:
huggingface-cli loginPaste your token when prompted and press Enter.

You're now ready to download Gemma 4! The model weights can be downloaded directly using Python. Create a new file called download_gemma.py and add the following code:
from transformers import AutoTokenizer, AutoModelForCausalLM
model_id = "google/gemma-4-it"
tokenizer = AutoTokenizer.from_pretrained(model_id)
model = AutoModelForCausalLM.from_pretrained(
model_id,
device_map="auto"
)Run it with python download_gemma.py. The download is approximately 5–9 GB depending on the model variant selected.
Gemma 4 comes in several sizes. Choosing the right one for your hardware ensures the best balance of speed, quality, and memory usage.
Best for: Low-resource machines, quick experiments
RAM needed: ~6 GB
Lightweight and fast — great for laptops and machines without a dedicated GPU.
Best for: Balanced performance on consumer hardware
RAM needed: ~14 GB
The sweet spot for most users — strong reasoning with manageable resource demands.
Best for: High-end workstations and servers
RAM needed: ~55 GB
Maximum capability for complex tasks — requires significant GPU memory or quantisation.
If your machine has limited VRAM or RAM, 4-bit quantisation lets you run larger models by compressing the model weights. This can cut memory usage by up to 75% with minimal quality loss — a game-changer for consumer hardware.
Modify your loading code to use the BitsAndBytesConfig as shown below:
from transformers import BitsAndBytesConfig
import torch
quant_config = BitsAndBytesConfig(
load_in_4bit=True,
bnb_4bit_compute_dtype=torch.float16
)
model = AutoModelForCausalLM.from_pretrained(
model_id,
quantization_config=quant_config,
device_map="auto"
)
With the model downloaded and loaded, it's time to run your first prompt! Add the following code to generate a response from Gemma 4:
input_text = "Explain quantum computing in simple terms."
inputs = tokenizer(input_text, return_tensors="pt").to("cuda")
outputs = model.generate(**inputs, max_new_tokens=200)
print(tokenizer.decode(outputs[0], skip_special_tokens=True))Run the script with python your_script.py. Within a few seconds — or moments if you have a GPU — Gemma 4 will generate its response directly in your terminal. Congratulations, you're now running a state-of-the-art AI model locally!

If the Python setup feels complex, Ollama is a fantastic alternative. It wraps the entire model management process into a single, easy-to-use command-line tool — no virtual environments or token setup needed.
Step 1: Download Ollama from ollama.com and install it like any regular application.
Step 2: Open a terminal and run:
ollama run gemma4Ollama automatically downloads the model and starts an interactive chat session. It's the fastest path from zero to running Gemma 4.
Prefer a visual chat interface instead of the terminal? Open WebUI paired with Ollama gives you a browser-based chat experience similar to ChatGPT — all running locally on your machine.
Run pip install open-webui in your terminal after ensuring Ollama is already installed and running.
Start the interface with open-webui serve and wait for the local server to initialise.
Navigate to http://localhost:3000 in your web browser to access the chat dashboard.
Choose gemma4 from the model dropdown and start chatting with a clean, intuitive interface.
Your GPU doesn't have enough VRAM. Switch to a smaller model variant (e.g. 2B) or enable 4-bit quantisation using BitsAndBytesConfig as shown in the earlier step.
Your Hugging Face token is missing or expired. Re-run huggingface-cli login and paste a fresh token. Make sure you've accepted the Gemma 4 licence on the model page.
CPU inference is significantly slower than GPU. Consider enabling device_map="cpu" with quantisation, or try Ollama which optimises CPU performance more aggressively.
Your virtual environment may not be activated. Run the activation command again and re-install dependencies with pip install transformers torch accelerate.
Following these seven steps takes most users between 20 and 45 minutes depending on internet speed and hardware setup. The Ollama method can cut this down to under 5 minutes for those who prefer simplicity over flexibility.
Ask Gemma 4 to write, review, debug, or explain code across dozens of programming languages. It excels at Python, JavaScript, and SQL.
Generate essays, summaries, emails, marketing copy, and creative writing with nuanced, context-aware output.
Ask complex questions, summarise documents, and get detailed explanations on virtually any topic — entirely offline.
The Hugging Face community has thousands of Gemma-based fine-tunes, adapters, and example notebooks. Browse the Models section and filter by "gemma" to discover specialised variants for coding, medicine, and more.
Using the PEFT library and LoRA adapters, you can fine-tune Gemma 4 on your own dataset with as little as 6 GB of VRAM. The Hugging Face documentation has detailed guides to get you started.
You've successfully installed Google's Gemma 4 Free Version and run your first AI inference locally. From here, the possibilities are virtually endless — build apps, automate tasks, or simply explore the frontiers of open-source AI from the comfort of your own machine.
Try different prompts, adjust generation parameters, and explore what Gemma 4 does best.
Share your projects and get help from thousands of developers on the Hugging Face forums.
Watch the Gemma model page for new releases, fine-tunes, and performance improvements.
How to Install Gemma 4 Free Version