🚀 Run SDXL Turbo Locally on Android (Offline)
This guide turns your Android phone into an offline AI image generator using Termux and OnnxStream. We use a Proot (Ubuntu) environment to ensure stability and avoid Android-specific compilation errors.
⚠️ Requirements:
RAM: 4GB minimum (System Requirement).
Note: The AI itself uses ~300MB RAM, but the compilation process needs more.
Storage: ~10GB free space.
Time: ~15-30 minutes.
Phase 1: Setup the Linux Environment 🐧
- Open Termux and update:
pkg update && pkg upgrade -y
- Install Ubuntu (Proot-Distro): This creates a stable Linux environment to fix the "Termux compatibility" issues mentioned in the docs.
pkg install proot-distro
proot-distro install ubuntu
proot-distro login ubuntu
Phase 2: Build the Engine 🛠️
- Install Dependencies:
apt update && apt install -y build-essential cmake git wget python3
- Clone the Code:
git clone https://github.com/vitoplantamura/OnnxStream
cd OnnxStream/src
- Compile:
We use
-DMAX_SPEED=OFFas recommended in the docs for Termux to prevent crashes/overheating.
mkdir build && cd build
cmake -DMAX_SPEED=OFF ..
cmake --build . --config Release
Phase 3: Run & Download 🎨
We use the built-in downloader to fetch the weights automatically into a clean folder (~/models).
- Run the Generator:
--download A: Automatically downloads the model if missing.--models-path ~/models: Saves the heavy files to a clean "models" folder.
./sd --turbo --download A --models-path ~/models --prompt "Cyberpunk city, neon lights, 8k"
💡 Pro Tips
- First Run: It will take a while to download the weights (~8GB). Ensure you are on WiFi.
- Output: The image is saved as
sd_output.pngin the currentbuildfolder. - View the Image: To see it in your Android Gallery, move it to internal storage:
cp sd_output.png /sdcard/Download/
Boom. You are live. 🚀