Stable Diffusion.cpp – Lightweight, High-Performance Stable Diffusion Inference in Pure C/C++

Stable Diffusion.cpp – Lightweight, High-Performance Stable Diffusion Inference in Pure C/C++

License: MIT
Model Type: Image Generation
Stable Diffusion.cpp is an open-source implementation of Stable Diffusion models optimized for CPU and GPU inference. Written in pure C/C++, it offers a lightweight and efficient alternative to traditional frameworks, supporting models like SD1.x, SD2.x, SDXL, and SD3/3.5. The project emphasizes minimal dependencies, low memory usage, and broad platform compatibility, including Windows, macOS, Linux, and Android (via Termux).

Key Features

  • Model Support: Compatible with SD1.x, SD2.x, SDXL, and SD3/3.5 models.
  • Quantization: Supports 2-bit, 3-bit, 4-bit, 5-bit, and 8-bit integer quantization for reduced memory usage.
  • Precision: Offers 16-bit and 32-bit floating-point precision.
  • Sampling Methods: Includes Euler A, Euler, Heun, DPM2, DPM++ 2M, DPM++ 2M v2, DPM++ 2S a, and LCM.
  • ControlNet Support: Integrates with ControlNet for enhanced image generation.
  • LoRA Support: Compatible with LoRA models for fine-tuning.
  • VAE Support: Handles standalone VAE models without conversion.
  • Flash Attention: Utilizes Flash Attention for memory optimization.
  • Cross-Platform Compatibility: Runs on Windows, macOS, Linux, and Android (via Termux).
  • Low Memory Usage: Requires approximately 2.3GB of RAM for generating a 512x512 image with fp16 precision.

Project Screenshots

Project Screenshot
Project Screenshot