Diffusers
raw JSON → 0.37.1 verified Tue May 12 auth: no python install: stale quickstart: stale
Hugging Face library for state-of-the-art diffusion models: Stable Diffusion, FLUX, SDXL, video generation, and more. Current version is 0.37.1. Core API: DiffusionPipeline.from_pretrained(). Always set torch_dtype=torch.float16 or bfloat16 — default float32 causes OOM on most GPUs.
pip install diffusers Common errors
error ModuleNotFoundError: No module named 'diffusers' ↓
cause The 'diffusers' library is not installed in your current Python environment or is not accessible on the Python path.
fix
Install the library using pip:
pip install diffusers error RuntimeError: CUDA out of memory. Tried to allocate ... MiB (GPU ...; ... GiB total capacity; ... GiB already allocated; ... bytes free; ... GiB reserved in total by PyTorch) ↓
cause The GPU lacks sufficient memory to perform the operation, typically due to a large model, high image resolution, or excessive batch size.
fix
Reduce batch size, lower image dimensions, enable CPU offloading (e.g.,
pipe.enable_model_cpu_offload()), or ensure torch_dtype=torch.float16 or torch.bfloat16 is set when loading the pipeline. error AttributeError: module 'diffusers' has no attribute 'SomePipelineClass' ↓
cause The requested pipeline class, module, or function ('SomePipelineClass') is either not available in your installed `diffusers` version or its name/import path has changed in a breaking update.
fix
Ensure your
diffusers library is up-to-date (pip install --upgrade diffusers). For very new models, you might need to install from the main branch (pip install git+https://github.com/huggingface/diffusers.git). error OSError: Error no file named diffusion_pytorch_model.bin ↓
cause A critical model checkpoint file (`diffusion_pytorch_model.bin`) or other necessary assets are missing or corrupted in the Hugging Face cache or the specified local path, preventing the model from loading.
fix
Clear the Hugging Face cache (
rm -rf ~/.cache/huggingface/hub) and attempt to load the model again, verifying the model identifier is correct and you have a stable internet connection. error ModuleNotFoundError: No module named 'diffusers.pipeline_utils' ↓
cause The internal import path for `pipeline_utils` (or components like `DiffusionPipeline` within it) has been refactored or moved in a newer version of the `diffusers` library.
fix
Update the import statement from
from diffusers.pipeline_utils import DiffusionPipeline to from diffusers import DiffusionPipeline. Warnings
breaking Not setting torch_dtype=torch.float16 loads the model in float32, typically requiring 14GB+ VRAM for SD 1.5 and 40GB+ for SDXL. Causes immediate CUDA OOM on most consumer GPUs. The most common LLM-generated diffusers bug. ↓
fix Always pass torch_dtype=torch.float16 (RTX 30xx and earlier) or torch_dtype=torch.bfloat16 (RTX 40xx / A100+) to from_pretrained().
breaking callback and callback_steps parameters deprecated across all pipelines. Raises FutureWarning now, will raise TypeError in future release. ↓
fix Replace with callback_on_step_end=fn and callback_on_step_end_tensor_inputs=['latents'].
breaking from_single_file() model config args (num_in_channels, scheduler_type, image_size, upcast_attention) deprecated since 0.28. These were SD-specific anti-patterns not supported in from_pretrained(). ↓
fix Pass a config= argument pointing to a Hub repo or local path instead. Remove per-component config args from the pipeline loading call.
breaking enable_model_cpu_offload() and enable_sequential_cpu_offload() require accelerate to be installed. Calling them without accelerate raises ImportError. ↓
fix pip install accelerate before calling any offload methods.
gotcha Model hub IDs change over time. 'CompVis/stable-diffusion-v1-4' and 'runwayml/stable-diffusion-v1-5' are outdated hub IDs from early tutorials. The current canonical SD 1.5 repo is 'stable-diffusion-v1-5/stable-diffusion-v1-5'. ↓
fix Use the current model IDs from https://huggingface.co/models. Old hub IDs from 2022-2023 tutorials may be deleted or moved.
gotcha Pipeline output is always a dataclass, not a tensor. pipe(...).images returns a list of PIL Images, not a tensor. Accessing .images[0] gives the first PIL Image. ↓
fix Use pipe(...).images[0] for the first image. To get numpy: pipe(...).images[0] then np.array(image). To get tensor: torch.from_numpy(np.array(image)).
gotcha Upgrading diffusers without matching transformers version can silently degrade output quality or cause errors. diffusers and transformers are tightly coupled — each diffusers release targets specific transformers versions. ↓
fix Upgrade both together: pip install -U diffusers transformers. Check release notes for minimum transformers version requirements.
breaking Installing `diffusers` versions that constrain `Pillow` to less than `10.0` (e.g., `diffusers<0.10.0`) will result in a build failure for `Pillow` on Python 3.13, specifically `KeyError: '__version__'`. Older `Pillow` versions are generally not compatible with Python 3.13's build environment. ↓
fix To use `diffusers` on Python 3.13, install `diffusers>=0.10.0` (which allows `Pillow>=10.0`). If you must use an older `diffusers` version that requires `Pillow<10.0`, you will need to use an older Python version (e.g., Python 3.11 or 3.12) where `Pillow<10.0` can be built.
Install
pip install diffusers[torch] pip install diffusers transformers accelerate Install compatibility stale last tested: 2026-05-12
python os / libc variant status wheel install import disk
3.10 alpine (musl) diffusers - - 1.91s 195.0M
3.10 alpine (musl) diffusers - - 1.89s 305.3M
3.10 alpine (musl) torch - - - -
3.10 slim (glibc) diffusers - - 1.44s 192M
3.10 slim (glibc) diffusers - - 15.81s 4.8G
3.10 slim (glibc) torch - - 10.94s 4.7G
3.11 alpine (musl) diffusers - - 2.97s 215.2M
3.11 alpine (musl) diffusers - - 2.87s 343.4M
3.11 alpine (musl) torch - - - -
3.11 slim (glibc) diffusers - - 2.37s 212M
3.11 slim (glibc) diffusers - - 20.69s 4.9G
3.11 slim (glibc) torch - - 15.45s 4.8G
3.12 alpine (musl) diffusers - - 2.82s 201.1M
3.12 alpine (musl) diffusers - - 2.83s 326.3M
3.12 alpine (musl) torch - - - -
3.12 slim (glibc) diffusers - - 2.81s 197M
3.12 slim (glibc) diffusers - - 21.28s 4.9G
3.12 slim (glibc) torch - - 14.91s 4.8G
3.13 alpine (musl) diffusers - - 2.72s 200.4M
3.13 alpine (musl) diffusers - - - -
3.13 alpine (musl) torch - - - -
3.13 slim (glibc) diffusers - - 2.86s 197M
3.13 slim (glibc) diffusers - - 18.69s 4.9G
3.13 slim (glibc) torch - - 13.50s 4.8G
3.9 alpine (musl) diffusers - - 2.27s 196.5M
3.9 alpine (musl) diffusers - - 1.74s 308.9M
3.9 alpine (musl) torch - - - -
3.9 slim (glibc) diffusers - - 1.90s 196M
3.9 slim (glibc) diffusers - - - -
3.9 slim (glibc) torch - - - -
Imports
- DiffusionPipeline wrong
pipe = DiffusionPipeline.from_pretrained('stable-diffusion-v1-5/stable-diffusion-v1-5') # Missing torch_dtype=torch.float16 — loads in float32, ~14GB VRAM, OOM on most GPUscorrectfrom diffusers import DiffusionPipeline import torch pipe = DiffusionPipeline.from_pretrained( 'stable-diffusion-v1-5/stable-diffusion-v1-5', torch_dtype=torch.float16 # REQUIRED — omitting uses float32 and will OOM on most GPUs ) pipe = pipe.to('cuda') image = pipe('An astronaut on Mars').images[0] - callback wrong
image = pipe( prompt, callback=my_callback, # deprecated callback_steps=1 # deprecated ).images[0]correctdef step_callback(pipe, step, timestep, callback_kwargs): # process latents here return callback_kwargs image = pipe( prompt, callback_on_step_end=step_callback, callback_on_step_end_tensor_inputs=['latents'] ).images[0]
Quickstart stale last tested: 2026-04-23
from diffusers import DiffusionPipeline
import torch
# Text-to-image
pipe = DiffusionPipeline.from_pretrained(
'stable-diffusion-v1-5/stable-diffusion-v1-5',
torch_dtype=torch.float16
).to('cuda')
image = pipe('A cat wearing a hat').images[0]
image.save('output.png')
# Memory-efficient: CPU offload (requires accelerate)
pipe.enable_model_cpu_offload()
# FLUX (latest high-quality model)
flux_pipe = DiffusionPipeline.from_pretrained(
'black-forest-labs/FLUX.1-schnell',
torch_dtype=torch.bfloat16
).to('cuda')
image = flux_pipe(
'An astronaut riding a horse on Mars',
guidance_scale=0.,
num_inference_steps=4
).images[0]