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.
- 2026/06/25 🚀 stable-diffusion.cpp now supports Krea2
- 2026/06/04 🚀 stable-diffusion.cpp now supports Ideogram4
- 2026/05/31 🚀 stable-diffusion.cpp now supports PiD
- 2026/05/27 🚀 stable-diffusion.cpp now supports Lens
- 2026/05/17 🚀 stable-diffusion.cpp now supports LTX-2.3
- 2026/04/11 🚀 stable-diffusion.cpp now uses a brand-new embedded web UI.
- 2026/01/18 🚀 stable-diffusion.cpp now supports FLUX.2-klein
- 2025/12/01 🚀 stable-diffusion.cpp now supports Z-Image
- 2025/11/30 🚀 stable-diffusion.cpp now supports FLUX.2-dev
- 2025/10/13 🚀 stable-diffusion.cpp now supports Qwen-Image-Edit / Qwen-Image-Edit 2509
- 2025/10/12 🚀 stable-diffusion.cpp now supports Qwen-Image
- 2025/09/14 🚀 stable-diffusion.cpp now supports Wan2.1 Vace
- 2025/09/06 🚀 stable-diffusion.cpp now supports Wan2.1 / Wan2.2
- 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
- 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
- Supported backends
- CPU (AVX, AVX2 and AVX512 support for x86 architectures)
- CUDA
- Vulkan
- Metal
- OpenCL
- SYCL
- Supported weight formats
- Pytorch checkpoint (.ckpt or .pth or .pt)
- Safetensors (.safetensors)
- GGUF (.gguf)
- Convert mode supports converting model weights to .gguf or .safetensors
- Supported platforms
- 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
- Cross-platform reproducibility
- --rng cuda, default, consistent with the stable-diffusion-webui GPU RNG
- --rng cpu, consistent with the comfyui RNG
- Embedds generation parameters into png output as webui-compatible text string
Generate an image with just one command
./bin/sd-cli -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.
For runtime and parameter backend placement, see the backend selection guide.
These projects wrap stable-diffusion.cpp for easier use in other languages/frameworks.
These projects use stable-diffusion.cpp as a backend for their image generation.
Thank you to all the people who have already contributed to stable-diffusion.cpp!