whatisgithub

What is gemma.cpp?

google/gemma.cpp — explained in plain English

Analysis updated 2026-06-24

6,898C++Audience · researcherComplexity · 4/5Setup · hard

In one sentence

A lightweight C++ program that runs Google's Gemma AI language models directly on your CPU with no GPU or cloud required, written to be small enough that researchers can read and modify how the model works.

Mindmap

mindmap
  root((gemma.cpp))
    What it does
      CPU-only inference
      No GPU needed
      Low-level study tool
    Models supported
      Gemma 2
      Gemma 3
      PaliGemma 2
    Platforms
      Linux
      Windows
      macOS
    Features
      Python bindings
      Training support
      SIMD optimization
Click or tap to explore — scroll the page freely

Code map

Detail Auto

An interactive map of this repo's files and how they connect — its source is parsed live in your browser. Click Visualize to build it.

filefunction / class

What do people build with it?

USE CASE 1

Run Gemma 2 or Gemma 3 language models locally on a laptop or desktop without a GPU or internet connection

USE CASE 2

Study the C++ source code to understand exactly how transformer inference works at a low level

USE CASE 3

Call a local Gemma model from a Python script using the included Python bindings

USE CASE 4

Experiment with training small Gemma models on a CPU without cloud infrastructure

What is it built with?

C++CMakePython

How does it compare?

google/gemma.cppfeiyangqingyun/qwidgetdemoserial-studio/serial-studio
Stars6,8986,8906,885
LanguageC++C++C++
Setup difficultyhardmoderateeasy
Complexity4/53/53/5
Audienceresearcherdeveloperops devops

Figures from each repo's GitHub metadata at analysis time.

How do you get it running?

Difficulty · hard Time to first run · 1h+

Requires CMake build tools and downloading model weights from Kaggle before the program runs.

So what is it?

gemma.cpp is a C++ program that runs Google's Gemma family of AI language models directly on a computer's processor, without needing a graphics card or cloud service. It is designed to be small and easy to understand, with a core implementation of around two thousand lines of code. The project targets researchers and developers who want to study or modify how a language model works at a low level. Most AI toolkits hide the computation behind layers of abstraction. gemma.cpp keeps things direct so that someone can read the code and see exactly what happens when the model generates text. It is not the recommended path for shipping a product, for that, Google points people toward standard Python-based tools. Supported models include Gemma 2, Gemma 3, and PaliGemma 2, covering sizes from 2 billion to 27 billion parameters. The program runs on Linux, Windows, and macOS, and works on any modern CPU. It achieves reasonable speed through a technique called SIMD, which lets the processor work on multiple numbers at once, adapting automatically to whatever hardware it finds. To use it, you download model weights from Kaggle (a data science platform), build the project with CMake (a common build tool), and run the resulting executable with a path to the weights file. A basic command-line interface lets you type prompts and read responses. There are also Python bindings so the engine can be called from Python code. The repository includes support for training as well as running models, which is less common in tools of this type. Contributions from the community are welcome, with active development happening on a separate branch from the stable release.

Copy-paste prompts

Prompt 1
Walk me through building gemma.cpp on macOS with CMake step by step, including where to download Gemma 2B weights from Kaggle and the exact commands to run a prompt.
Prompt 2
Show me how to call gemma.cpp from Python using its bindings to generate a response to a prompt without using any cloud API.
Prompt 3
In gemma.cpp source code, where does the model compute the next token? Explain the forward pass loop in plain terms.
Prompt 4
Compare the inference speed of gemma.cpp on a modern laptop CPU for a 2B parameter model, what prompt length and generation speed should I expect?

Frequently asked questions

What is gemma.cpp?

A lightweight C++ program that runs Google's Gemma AI language models directly on your CPU with no GPU or cloud required, written to be small enough that researchers can read and modify how the model works.

What language is gemma.cpp written in?

Mainly C++. The stack also includes C++, CMake, Python.

How hard is gemma.cpp to set up?

Setup difficulty is rated hard, with roughly 1h+ to a first successful run.

Who is gemma.cpp for?

Mainly researcher.

Open on GitHub → Ask about another repo

This repo across BitVibe Labs

Verify against the repo before relying on details.