Diffusion model(SD,Flux,Wan,...) inference in pure C/C++
Note that this project is under active development.
API and command-line option may change frequently.
-
2025/10/13 🚀 stable-diffusion.cpp now supports Qwen-Image-Edit / Qwen-Image-Edit 2509
👉 Details: PR #877 -
2025/10/12 🚀 stable-diffusion.cpp now supports Qwen-Image
👉 Details: PR #851 -
2025/09/14 🚀 stable-diffusion.cpp now supports Wan2.1 Vace
👉 Details: PR #819 -
2025/09/06 🚀 stable-diffusion.cpp now supports Wan2.1 / Wan2.2
👉 Details: PR #778
- Plain C/C++ implementation based on ggml, working in the same way as llama.cpp
- Super lightweight and without external dependencies
- Supported models
- Image Models
- SD1.x, SD2.x, SD-Turbo
- SDXL, SDXL-Turbo
- SD3/SD3.5
- Flux-dev/Flux-schnell
- Chroma
- Qwen Image
- Image Edit Models
- Video Models
- PhotoMaker support.
- Control Net support with SD 1.5
- LoRA support, same as stable-diffusion-webui
- Latent Consistency Models support (LCM/LCM-LoRA)
- Faster and memory efficient latent decoding with TAESD
- Upscale images generated with ESRGAN
- Image Models
- Supported backends
- CPU (AVX, AVX2 and AVX512 support for x86 architectures)
- CUDA
- Vulkan
- Metal
- OpenCL
- SYCL
- Supported weight formats
- Pytorch checkpoint (
.ckpt
or.pth
) - Safetensors (
./safetensors
) - GGUF (
.gguf
)
- Pytorch checkpoint (
- Supported platforms
- Linux
- Mac OS
- Windows
- Android (via Termux, Local Diffusion)
- Flash Attention for memory usage optimization
- Negative prompt
- stable-diffusion-webui style tokenizer (not all the features, only token weighting for now)
- VAE tiling processing for reduce memory usage
- Sampling method
Euler A
Euler
Heun
DPM2
DPM++ 2M
DPM++ 2M v2
DPM++ 2S a
LCM
- Cross-platform reproducibility (
--rng cuda
, consistent with thestable-diffusion-webui GPU RNG
) - Embedds generation parameters into png output as webui-compatible text string
- Download pre-built binaries from the releases page
- Or build from source by following the build guide
-
download weights(.ckpt or .safetensors or .gguf). For example
- Stable Diffusion v1.5 from https://huggingface.co/runwayml/stable-diffusion-v1-5
curl -L -O https://huggingface.co/runwayml/stable-diffusion-v1-5/resolve/main/v1-5-pruned-emaonly.safetensors
./bin/sd -m ../models/v1-5-pruned-emaonly.safetensors -p "a lovely cat"
For detailed command-line arguments, check out cli doc.
If you want to improve performance or reduce VRAM/RAM usage, please refer to performance guide.
- SD1.x/SD2.x/SDXL
- SD3/SD3.5
- Flux-dev/Flux-schnell
- FLUX.1-Kontext-dev
- Chroma
- 🔥Qwen Image
- 🔥Qwen Image Edit/Qwen Image Edit 2509
- 🔥Wan2.1/Wan2.2
- LoRA
- LCM/LCM-LoRA
- Using PhotoMaker to personalize image generation
- Using ESRGAN to upscale results
- Using TAESD to faster decoding
- Docker
- Quantization and GGUF
These projects wrap stable-diffusion.cpp
for easier use in other languages/frameworks.
- Golang (non-cgo): seasonjs/stable-diffusion
- Golang (cgo): Binozo/GoStableDiffusion
- C#: DarthAffe/StableDiffusion.NET
- Python: william-murray1204/stable-diffusion-cpp-python
- Rust: newfla/diffusion-rs
- Flutter/Dart: rmatif/Local-Diffusion
These projects use stable-diffusion.cpp
as a backend for their image generation.
- Jellybox
- Stable Diffusion GUI
- Stable Diffusion CLI-GUI
- Local Diffusion
- sd.cpp-webui
- LocalAI
- Neural-Pixel
Thank you to all the people who have already contributed to stable-diffusion.cpp!