AI & Machine Learning

AI Runs Locally on Your Phone: Gemma 4 & Termux Guide

Your phone just became a server. Google's Gemma 4 AI can now run entirely on your device, no internet or API keys needed.

A person holding a smartphone displaying an AI chat interface, with a subtle overlay suggesting local processing.

Key Takeaways

  • Google's Gemma 4 AI model can now run locally on Android phones using Termux and Ollama.
  • This setup eliminates the need for internet connectivity and API keys, making AI more accessible and private.
  • Challenges include thermal throttling and aggressive Android memory management, but solutions are emerging.

Forget the cloud. For most people, that means remembering passwords and worrying about data leaks. For developers? It means waiting. Waiting for a spinner. Waiting for an API key. Waiting for a bill. Google’s Gemma 4 changes that. Or at least, it could. This isn’t about speed, though 7 tokens a second on a phone is pretty decent. It’s about access. It’s about control.

We’re talking about turning that pocket-sized slab of glass and silicon into a genuine AI server. No cloud. No paid APIs. Just you, your phone, and a model that used to require a small data center.

Offline AI: Why This Actually Matters

This is what breaks the chains. For too long, powerful AI has been a privilege. You needed a beefy rig, expensive cloud credits, or a willingness to ship your data off to some distant server farm. The student in Nigeria with an aging phone? Locked out. The developer during a blackout? Frustrated.

This is about democratizing computation. It’s about agency. It’s a quiet revolution happening in your pocket, powered by Gemma 4 and a surprisingly capable terminal emulator called Termux.

Running a cutting-edge AI model locally on a phone isn’t some theoretical exercise anymore. It’s happening. And it’s more accessible than you think. The implication here is simple: the line between client and server just blurred into non-existence for a whole class of AI applications.

I build on a cracked iPhone 7 and an aging Android phone. I don’t have a GPU. I don’t have cloud credits. What I have is a stubborn belief that my location shouldn’t determine my access to the most powerful technology of our generation.

That sentiment, expressed by our guide here, is the driving force. It’s why this news isn’t just about Gemma 4; it’s about what Gemma 4 enables.

Picking Your Pocket-Sized Brain

Gemma 4 isn’t a monolith. Google released it in variants. For phone duty, two stand out: the E2B (2.3 billion parameters) and the E4B (4.5 billion parameters). The E2B is the sensible choice for most phones – lightweight, but still capable. If your phone has a generous 12GB+ of RAM, you might be able to push the E4B. This guide focuses on the E2B, because frankly, if it can run on an aging device, it’s already won half the battle.

The Termux Gambit

Forget the Play Store. The real magic happens with Termux from F-Droid. It’s a Linux environment for Android that doesn’t require root. Install it. Then, a quick pkg update && pkg upgrade and a few essential tools: python, git, cmake, gcc. Standard fare for anyone who’s ever compiled anything.

Then comes Ollama. The official docs are for Linux and macOS. On Termux, it’s a community dance. Clone the repo, cd into it, and follow the specific Termux instructions. This isn’t a click-and-drag operation. You’re compiling on a phone. It takes time. Patience, grasshopper.

Summoning Gemma 4

Once Ollama is chugging along in Termux, the actual model download is hilariously simple: ollama pull gemma4:2b. That’s it. Several gigabytes, so definitely hit that WiFi button.

And to run it? ollama run gemma4:2b. You’re now interacting with an AI that lives entirely on your phone. No internet. No API keys. No per-token charges. Your data stays put. This is the dream, finally tangible.

When Your Phone Becomes a Server

Here’s where it really gets interesting. Ollama punches out a local API on port 11434. That means other devices on your WiFi can talk to your phone. Your phone becomes a localized, private AI server.

Imagine it: your laptop, your tablet, another phone on the same network, all pinging your main device for AI smarts. No central cloud. Just a distributed, self-hosted network. The privacy implications are massive.

The Inevitable Hiccups

Let’s not pretend it’s all sunshine and instant responses. Phones get hot. Twenty minutes of AI crunching, and your device will feel like a small furnace. Response times will dip. You’ll need to manage usage, maybe batch requests.

Android is also notoriously grabby with RAM. If you leave Termux for too long, the OS might just kill the AI process. Keeping the phone plugged in and Termux foregrounded seems to be the workaround.

And speed? Expect 7-8 tokens/second on high-end devices. Lower-end phones will be slower. It’s usable for chat, but not for anything requiring instantaneous feedback.

But these are limitations, not deal-breakers. They are engineering challenges, not fundamental impossibilities.

What This Unlocks

Once you’ve seen it work, you start seeing possibilities everywhere. A chatbot for a local business that doesn’t need an internet connection. An offline PDF reader that actually understands the text. A coding assistant that works even when the network is dead. A classroom tool that doesn’t rely on always-on connectivity.

This is the start. And it’s happening on the devices we already own.


🧬 Related Insights

Jordan Kim
Written by

Infrastructure reporter. Covers CNCF projects, cloud-native ecosystems, and OSS-backed platforms.

Worth sharing?

Get the best Open Source stories of the week in your inbox — no noise, no spam.

Originally reported by Dev.to

Stay in the loop

The week's most important stories from Open Source Beat, delivered once a week.