← How-Tos
raspberry-pi Mar 26, 2026 ◑ 5 views ◯ 1 min read

Running Stable Diffusion on Raspberry Pi 5

raspberry pistable diffusionaiimage generation

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

ApproachPi 5 SpeedQuality
Full SD 1.545-90 min per imageGood
Quantized/pruned models10-20 min per imageOK
Remote inference (Pi as client)FastFull quality
OnnxStream (ultra-light)5-15 min per imageBasic

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.