DEV Community

Cover image for How to Run DeepSeek R1 Locally on Your Android Device
Majdi Saibi
Majdi Saibi

Posted on

168 2 2 2 1

How to Run DeepSeek R1 Locally on Your Android Device

Introduction

The AI revolution is no longer confined to high-end servers or cloud platforms. With models like DeepSeek R1—a state-of-the-art reasoning model that rivals top-tier commercial offerings—you can now harness advanced AI capabilities directly on your Android device. In this guide, I’ll show you how to deploy DeepSeek R1 locally for privacy, customization, and offline use.


Why Run DeepSeek R1 on Android?

  • Privacy: Process sensitive data locally without cloud dependencies.
  • Cost Efficiency: Avoid API fees (DeepSeek’s API costs ~5% of OpenAI’s).
  • Offline Access: Use AI even without an internet connection.
  • Customization: Fine-tune models for niche applications (coding, creative writing, etc.).

Prerequisites

  1. Hardware:
    • Android device with ≥8GB RAM (for 8B/14B models).
    • Snapdragon 8 Gen 2/3 or equivalent processor.
    • ≥12GB storage space.
  2. Software:
    • Termux (Linux terminal emulator).
    • Basic command-line familiarity.

Step 1: Install Termux and Dependencies

  1. Download Termux: Grab the latest APK from Termux’s GitHub.
  2. Set Up Termux:
   termux-setup-storage  # Grant storage permissions
   pkg update && pkg upgrade  # Update packages
   pkg install git cmake golang libjpeg-turbo  # Install dependencies
Enter fullscreen mode Exit fullscreen mode

Step 2: Build Ollama from Source

Ollama is a lightweight tool to manage AI models.

  1. Clone the Repository:
   git clone --depth 1 https://github.com/ollama/ollama.git
   cd ollama
Enter fullscreen mode Exit fullscreen mode
  1. Compile Ollama:
   go generate ./...
   go build .  # Build the Ollama binary
Enter fullscreen mode Exit fullscreen mode

Step 3: Download DeepSeek R1 Models

For Android, use distilled or quantized models:

  • Recommended: deepseek-r1:1.5b (5.7GB) or deepseek-r1:8b-q4 (quantized).

Pull the Model:

./ollama run deepseek-r1:8b  # Download the 8B model
Enter fullscreen mode Exit fullscreen mode

Step 4: Run DeepSeek R1

  1. Start the Ollama Server:
   ./ollama serve &  # Run in the background
Enter fullscreen mode Exit fullscreen mode
  1. Interact with the Model:
   ./ollama run deepseek-r1:8b
   >>> "Write Python code to calculate a Fibonacci sequence"
Enter fullscreen mode Exit fullscreen mode

Optimizing Performance

  • Use Quantized Models: Reduce RAM usage by 30% with deepseek-r1:8b-q4.
  • Prevent Sleep: Keep Termux active with:
  pkg install termux-services
  sv-enable termux-wake-lock
Enter fullscreen mode Exit fullscreen mode
  • Free Up RAM: Close background apps before running models.

Troubleshooting

  • Port Conflicts:
  ./ollama serve --port 8080 &  # Use a different port
Enter fullscreen mode Exit fullscreen mode
  • Out of Memory: Monitor RAM with top and switch to smaller models.
  • Model Not Found: Ensure downloads complete with ollama pull deepseek-r1:8b.

Conclusion

Running DeepSeek R1 on Android unlocks private, offline AI for coding, research, and creative projects. With this guide, you’re ready to experiment with cutting-edge models without relying on the cloud. Share your results, tweak the setup, and push the boundaries of mobile AI!

Further Reading:

Imagine monitoring actually built for developers

Billboard image

Join Vercel, CrowdStrike, and thousands of other teams that trust Checkly to streamline monitor creation and configuration with Monitoring as Code.

Start Monitoring

Top comments (15)

Collapse
 
venkatmidhunmareedu profile image
M V Midhun

Hey when I tried this command :
go generate ./...
I get this error:

make: *** No targets specified and no makefile found. Stop.
llama/llama.go:3: running "make": exit status 2

Please help.

Collapse
 
klausgreiner profile image
Klaus Greiner Fiorini

read development.md inside the folder ollama
u probably need to run
make -j 5

Collapse
 
venkatmidhunmareedu profile image
M V Midhun

Image description

It got stuck here 🥲

Thread Thread
 
karthik_murali_206cbb209b profile image
Karthik Murali

i also stuck here

Thread Thread
 
majdisaibi profile image
Majdi Saibi

Hey 😊
Can you try

go generate ./..

(just 3 dots after the /)
I guess I made a typo 😅

Collapse
 
majdisaibi profile image
Majdi Saibi

Hey 😊
Can you try

go generate ./..

(just 3 dots after the /)
I guess I made a typo 😅

Collapse
 
venkatmidhunmareedu profile image
M V Midhun

Hey I found a solution to install ollama easily in termux.

I found it on reddit. Here is the link :-
reddit.com/r/LocalLLaMA/s/itc8nSYDEj

Thread Thread
 
majdisaibi profile image
Majdi Saibi

Glad to hear that. Thanks for sharing the link.

Collapse
 
dev-shivamverma profile image
shivam

I want to tinker a little bit. I want the model to save context and memory about me in every season in a json and use that as input in every chat to customize the responses! How can I do that!
Can you give an idea?? 💡

Collapse
 
noceb0 profile image
Nameless Nocebo

So now it's just saying permission denied, is everyone who didn't manage to install on time fucked? I don't get it

Image description

Collapse
 
fibonacci_20 profile image
Lara F

How fast is deepseek-r1-1.5b running for you on pixel phones? it's super slow for me...

Collapse
 
ninjatheory profile image
Jinnah

Which model of pixel do you own? I'm also thinking of running it on my Redmagic 8s pro Snapdragon 888 gen 2 with 16gb ram can boost the ram to 26gb if needed.

Collapse
 
fibonacci_20 profile image
Lara F

I'm trying it on Pixel 9 Pro

Thread Thread
 
ninjatheory profile image
Jinnah

if you can pick up a Redmagic 8s pro even 9 pros they cost less than half of top-end phones like S24 Ultra iPhone etc they are way more powerful. Also, your pixel Google tensor isn't that Samsung Exynos CPU just renamed to Google Tensor as they are good CPUs they are more optimised for real-world use i.e longer better battery life but when it comes to raw power speed they don't really excel. Your other option is to root your Pixel then you will have full system access it could run faster in theory!

Collapse
 
ninjatheory profile image
Jinnah

Snapdragon 888 Tab S8 Ultra 256GB 12GB RAM Will this be okay to run deepseek with Termux ??

The Most Contextual AI Development Assistant

Pieces.app image

Our centralized storage agent works on-device, unifying various developer tools to proactively capture and enrich useful materials, streamline collaboration, and solve complex problems through a contextual understanding of your unique workflow.

👥 Ideal for solo developers, teams, and cross-company projects

Learn more

👋 Kindness is contagious

Immerse yourself in a wealth of knowledge with this piece, supported by the inclusive DEV Community—every developer, no matter where they are in their journey, is invited to contribute to our collective wisdom.

A simple “thank you” goes a long way—express your gratitude below in the comments!

Gathering insights enriches our journey on DEV and fortifies our community ties. Did you find this article valuable? Taking a moment to thank the author can have a significant impact.

Okay