#stable-diffusion #flux #ai

sys diffusion-rs-sys

Rust bindings for stable-diffusion.cpp (FFI bindings)

13 releases

Uses new Rust 2024

0.1.12 Sep 9, 2025
0.1.11 Jul 17, 2025
0.1.9 Apr 6, 2025
0.1.8 Feb 24, 2025
0.1.3 Nov 14, 2024

#1521 in Machine learning

33 downloads per month
Used in diffusion-rs

MIT license

9MB
147K SLoC

C++ 70K SLoC // 0.1% comments C 29K SLoC // 0.0% comments CUDA 13K SLoC // 0.0% comments GLSL 10K SLoC // 0.0% comments OpenCL 8K SLoC Metal Shading Language 6K SLoC // 0.0% comments Objective-C 5.5K SLoC // 0.0% comments Rust 2K SLoC // 0.0% comments WebGPU Shader Language 2K SLoC // 0.0% comments Python 122 SLoC // 0.1% comments

diffusion-rs

Latest version Documentation

Rust bindings to https://github.com/leejet/stable-diffusion.cpp

Features Matrix

Windows Mac Linux
vulkan ⛓️‍💥 ✅️
metal - ✅️ -
cuda - ✅️
rocm - ⛓️‍💥
sycl - ✅️

✅️: Working

❌: See this cargo issue

⛓️‍💥 : Issues when linking libraries

Usage

use diffusion_rs::{api::gen_img, preset::{Preset,PresetBuilder}};
let (mut config, mut model_config) = PresetBuilder::default()
            .preset(Preset::SDXLTurbo1_0Fp16)
            .prompt("a lovely duck drinking water from a bottle")
            .build()
            .unwrap();
gen_img(&mut config, &mut model_config).unwrap();

Troubleshooting

  • Something other than Windows/Linux isn't working!
    • I don't have a way to test these platforms, so I can't really help you.
  • I get a panic during binding generation build!
    • You can attempt to fix it yourself, or you can set the DIFFUSION_SKIP_BINDINGS environment variable. This skips attempting to build the bindings whatsoever and copies the existing ones. They may be out of date, but it's better than nothing.
      • DIFFUSION_SKIP_BINDINGS=1 cargo build
    • If you can fix the issue, please open a PR!

Roadmap

  1. Ensure that the underline cpp library compiles on supported platforms
  2. Build an easy to use library with model presets
  3. Automatic library publishing on crates.io by gh actions
  4. Maybe prebuilt CLI app binaries

Dependencies