stable-diffusion.cpp: Diffusion Inference in Pure C/C++
Diffusion model(SD,Flux,Wan,Qwen Image,Z-Image,...) inference in pure C/C++
At a glance
- What is it?
- A ggml-based runtime that runs SD, Flux, Wan and Qwen Image checkpoints from a single C++ binary. Here is what it does, how to install it, and where it stops being the right tool.
- Who is it for?
- Adopt stable-diffusion.cpp if you want diffusion inference inside a C/C++ program, a CLI pipeline, or a small HTTP service without a Python runtime, and you accept that the README states the API and command-line options may change frequently. Do not adopt it if you need a node graph editor, a plugin ecosystem, or a stable long-term interface, because this is a single-binary runtime with a moving CLI and no visual graph.
- Can I use it commercially?
- Yes. MIT is a permissive licence: you can use, modify and sell software built on it, as long as you keep its copyright and licence notices.
- Is it still maintained?
- Yes. The repository last received commits 1 day ago.
- What is it written in?
- Mainly C++, according to GitHub's language statistics.
Answers come from the project's GitHub data, last synced on September 17, 2026, and from our analysis. They are not legal advice.
DEEP OPEN-SOURCE ANALYSIS
What stable-diffusion.cpp replaces, and for whom
Most diffusion tooling assumes Python. A checkpoint is loaded by PyTorch, sampling loops live in Python, and the interface is either a script or a web UI. That is fine until you want image generation inside a C++ application, a small container, or a machine where installing CUDA-enabled PyTorch is the hard part.
stable-diffusion.cpp takes the other route. The README describes it as a plain C/C++ implementation based on ggml, working in the same way as llama.cpp. The comparison is deliberate: llama.cpp made local LLM inference a single compiled binary, and this project applies that shape to diffusion models. The README lists the audience implicitly through its feature set: a command-line tool, a server example under examples/server, and bindings for Go and other languages listed at the end of the README.
It is for people who already know which checkpoint they want and want to run it without a Python stack. It is not a hosted service, not a training framework, and not a visual editor.
How the ggml graph and the sd-cli binary fit together
The architecture follows the llama.cpp pattern. Model weights are read from PyTorch checkpoints (.ckpt, .pth, .pt), safetensors, or GGUF. The graph is built in C++ over ggml tensors and executed on one of the backends the README lists: CPU with AVX, AVX2 and AVX512 on x86, CUDA, Vulkan, Metal, OpenCL, or SYCL. There is no Python interpreter in the loop and the README states there are no external dependencies beyond the build itself.
Around that core the project layers the features people expect from a diffusion runtime: negative prompts, LoRA, ControlNet for SD 1.5, IP-Adapter for SD 1.5 and SDXL, PhotoMaker, ADetailer, TAESD for faster latent decoding, ESRGAN upscaling, and VAE tiling to reduce memory use. Sampling methods include Euler A, Euler, Heun, DPM2, DPM++ 2M, DPM++ 2M v2, DPM++ 2S a, ER-SDE and LCM.
One detail worth knowing before you build a pipeline: reproducibility is a flag, not a default guarantee. The README documents --rng cuda as the default, matching the stable-diffusion-webui GPU RNG, and --rng cpu as matching the comfyui RNG. If you compare outputs across two machines, that flag decides whether the comparison means anything. Generation parameters are also embedded into PNG output as a webui-compatible text string, which makes images traceable back to their settings.
Installing stable-diffusion.cpp and generating a first image
The README gives two paths. You can download pre-built binaries from the releases page, or build from source by following the build guide in docs/build.md. No package manager install is documented.
Model weights are a separate download. The README uses Stable Diffusion v1.5 as its example, fetching the safetensors file with curl:
curl -L -O https://huggingface.co/stable-diffusion-v1-5/stable-diffusion-v1-5/resolve/main/v1-5-pruned-emaonly.safetensorsAfter that, the README's one-command example points the sd-cli binary at the model with -m and passes the prompt with -p:
./bin/sd-cli -m ../models/v1-5-pruned-emaonly.safetensors -p "a lovely cat"The binary writes an image file and, per the feature list, embeds the generation parameters into the PNG as a webui-compatible string. The README points to examples/cli/README.md for the full argument list, and that is where you should look before scripting anything, because the option set is large.
If you want an HTTP surface instead of a CLI, the repository contains examples/server, and the README links a Docker guide at docs/docker.md. Both are documented in the repository rather than in the README body, so read those files before assuming a deployment shape.
Where the moving CLI and model sprawl bite
The README carries an explicit warning near the top: the project is under active development and the API and command-line option may change frequently. That is the main practical cost. A script built against today's flags can break on a later release, and the version strings in the release list (master-869-07a85c7 and similar) suggest continuous snapshots rather than a slow, versioned interface.
The second cost is breadth. The supported model list is long: SD1.x through SD3.5, FLUX.1 and FLUX.2 variants, Chroma, Qwen Image, Z-Image, Krea2, Ideogram4, and video models including Wan2.1/Wan2.2, MiniMax-H3 and LTX-2.3/LTX-2.5. Each family has its own docs page, which means the project is really a collection of per-architecture implementations sharing a runtime. A bug or a missing feature in one family is not fixed by the others.
Memory is the third constraint. The README offers Flash Attention, VAE tiling and a performance guide specifically for reducing VRAM and RAM use, which tells you large checkpoints do not fit comfortably on small GPUs without those measures. If your target is a laptop with a modest GPU and a 12B-parameter video model, this is the wrong tool, and no amount of tiling changes that.
stable-diffusion.cpp compared with a node-graph UI
The obvious alternative is ComfyUI, and the difference is not speed but control flow. ComfyUI is a Python application with a node graph: you wire loaders, samplers and post-processing nodes together, and the graph is the program. Extending it means writing Python nodes, and the runtime is Python plus PyTorch.
stable-diffusion.cpp inverts that. The program is a compiled binary with fixed flags, and extending it means editing C++ and rebuilding. There is no graph to rearrange at runtime and no plugin market. What you get in exchange is a process with no Python dependency that can be embedded in a C++ application, shipped in a small container, or driven from a Go binding listed in the README.
The README even acknowledges the UI gap historically: an April 2026 news entry notes a brand-new embedded web UI. That is a convenience layer over the same binary, not a node editor. If your workflow depends on sharing graphs with other people, stay where those graphs live.
Licence, upgrades and what maintenance costs you
The project is MIT licensed, which is permissive and places few obligations on how you redistribute the binary or embed it. That covers the project's own code only. Model weights are separate artifacts with their own licences, and the README's example points at a Hugging Face repository for SD 1.5 rather than bundling anything. Check the licence of each checkpoint you download; the MIT licence here says nothing about them.
Upgrade cost is dominated by the CLI warning. Releases appear as dated master snapshots, and the release list shows several within a single day, so there is no slow release train to sit on. Pinning a specific build and reading the changelog between builds is the realistic approach.
The repository is not archived, and the last push was on 2026-09-14, two days before this was written. Development is clearly ongoing, which is also why the interface is unstable. Treat the binary as a dependency you re-verify on upgrade, not one you install once and forget.
Editorial conclusion
Adopt stable-diffusion.cpp if you want diffusion inference inside a C/C++ program, a CLI pipeline, or a small HTTP service without a Python runtime, and you accept that the README states the API and command-line options may change frequently. Do not adopt it if you need a node graph editor, a plugin ecosystem, or a stable long-term interface, because this is a single-binary runtime with a moving CLI and no visual graph. Before committing, verify two things yourself: that your exact checkpoint family appears in the supported model list with its own docs page, and that a backend matching your hardware (CUDA, Vulkan, Metal, OpenCL, SYCL or CPU) builds from the build guide on your machine.
Frequently asked questions
What is stable-diffusion.cpp?
It is a diffusion model inference implementation written in pure C/C++ and built on ggml, following the same approach as llama.cpp. It runs image models such as SD, SDXL, FLUX and Qwen Image, plus video models including Wan and LTX, from a compiled binary rather than a Python stack.
How do I install stable-diffusion.cpp?
The README gives two options: download pre-built binaries from the releases page, or build from source following the build guide in docs/build.md. No package manager installation is documented. Model weights are downloaded separately, for example the SD 1.5 safetensors file from Hugging Face.
How do I use stable-diffusion.cpp?
The README's quick start downloads a checkpoint and then runs the sd-cli binary with -m pointing at the model file and -p carrying the prompt. The full argument list lives in examples/cli/README.md. A server example also exists under examples/server for HTTP use.
What is the difference between stable-diffusion.cpp and ComfyUI?
ComfyUI is a Python application built around a node graph that acts as the program, with extension through Python nodes. stable-diffusion.cpp is a compiled C/C++ binary driven by command-line flags, with no Python dependency and no node graph, though the README notes an embedded web UI was added in April 2026.
Is there an alternative to stable-diffusion.cpp for Python users?
If your workflow is already Python and PyTorch, a node-graph UI such as ComfyUI covers the same generation tasks with a visual editor and a plugin ecosystem. The trade-off is that you keep the Python runtime and lose the ability to embed inference directly in a C/C++ program.
Community notes