Running Stable Diffusion on Raspberry Pi 5
The honest answer: full Stable Diffusion is impractical on any Pi. But there are ways to run lightweight AI image generation that are actually usable.
The Reality
| Approach | Pi 5 Speed | Quality |
|---|---|---|
| Full SD 1.5 | 45-90 min per image | Good |
| Quantized/pruned models | 10-20 min per image | OK |
| Remote inference (Pi as client) | Fast | Full quality |
| OnnxStream (ultra-light) | 5-15 min per image | Basic |
Realistically: use the Pi 5 as a remote client, not a local GPU.
Option 1 โ OnnxStream (Most Viable Locally)
OnnxStream is specifically designed for low-memory inference:
git clone https://github.com/vitoplantamura/OnnxStream
cd OnnxStream/src
cmake -DXNNPACK_ENABLED=ON . && make
Download SD 1.4 ONNX weights (quantized, ~1GB).
Generates 512x512 images in 10-20 minutes using 1GB RAM.
Option 2 โ Remote Inference, Pi as Client
Run Stable Diffusion on a proper GPU machine, expose the API, call it from the Pi:
import requests, base64
response = requests.post("http://192.168.1.x:7860/sdapi/v1/txt2img", json={
"prompt": "workshop in East Tennessee, cinematic",
"width": 512, "height": 512, "steps": 20
})
img_data = base64.b64decode(response.json()['images'][0])
with open("output.png", "wb") as f:
f.write(img_data)
This is the practical approach for any Pi model.
Option 3 โ API-Based Generation
Use Stable Diffusion via API (Stability AI, Replicate, etc.) from the Pi:
import requests
response = requests.post(
"https://api.stability.ai/v1/generation/stable-diffusion-v1-6/text-to-image",
headers={"Authorization": "Bearer your_api_key"},
json={"text_prompts": [{"text": "workshop"}], "width": 512, "height": 512}
)
Fast, full quality, minimal Pi resource usage. Not free.
Bottom Line
Pi 5 is a capable small computer but it has no GPU. For local image generation, OnnxStream works but is slow. For anything practical, use a remote GPU or an API.