Reducing diffusers memory: offloading, device_map, VAE slicing
Answer: Large diffusion models often exceed GPU memory; use more than one GPU, offload pipeline components to the CPU, or load in 4-bit.
Multiple GPUs
- The
balanceddevice placement strategy evenly splits the pipeline across all available devices; inspect it withhf_device_map. - Sharded checkpoints load one shard at a time; sharding is recommended when the fp32 checkpoint is greater than 5GB.
- Use
reset_device_mapto reset thedevice_mapbefore calling.to()or offload methods on a device-mapped pipeline.
Offloading on one GPU
- CPU offloading moves weights from the GPU to the CPU; it dramatically reduces memory but is extremely slow.
- Model offloading moves entire models to the GPU, a faster alternative; enable it with
enable_model_cpu_offload.
VAE
VAE slicing decodes one image at a time instead of all images in a batch at once. VAE tiling divides an image into smaller overlapping tiles.
Quantization
Load in 4-bit with bitsandbytes to use less memory.
Artifacts
See also
Claims
- id: C1 claim: balanced splits a pipeline evenly across devices. source: S1 evidence: "strategy evenly splits the pipeline across all available devices."
- id: C2 claim: CPU offloading is extremely slow. source: S1 evidence: "but it is also extremely slow"
- id: C3 claim: Model offloading is the faster alternative. source: S1 evidence: "makes model offloading a faster alternative."
- id: C4 claim: 4-bit bitsandbytes reduces memory. source: S2 evidence: "To use less memory, load in 4-bit with bitsandbytes."
Sources
- [S1] Reduce memory usage. Hugging Face docs. https://huggingface.co/docs/diffusers/optimization/memory . License: Apache-2.0 (huggingface docs repos). Accessed 2026-11-09.
- [S2] Quickstart. Hugging Face docs. https://huggingface.co/docs/diffusers/quicktour . License: Apache-2.0 (huggingface docs repos). Accessed 2026-11-09.
License: this note is CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Summary by iinventedlight (AI-assisted). Sources: Hugging Face docs (huggingface/transformers, huggingface/huggingface_hub, huggingface/diffusers on GitHub), Apache License 2.0 (https://www.apache.org/licenses/LICENSE-2.0). Text was condensed and changed from the originals.
License: CC-BY-4.0 · Summary by iinventedlight (AI-assisted). Sources: Hugging Face docs, Reduce memory usage, Apache-2.0 (huggingface docs repos); Hugging Face docs, Quickstart, Apache-2.0 (huggingface docs repos).
Cite this
iinventedlight. 2026. "Reducing diffusers memory: offloading, device_map, VAE slicing." iinventedlight Library, iil:note:0370mxxc, version of 2026-11-09. https://iinventedlight.com/library/notes/hf-diffusers-memory/. License: CC-BY-4.0.
@misc{iil_note_0370mxxc,
author = {{iinventedlight}},
title = {{Reducing diffusers memory: offloading, device\_map, VAE slicing}},
howpublished = {iinventedlight Library},
year = {2026},
date = {2026-11-09},
url = {https://iinventedlight.com/library/notes/hf-diffusers-memory/},
note = {Permanent ID iil:note:0370mxxc. License: CC-BY-4.0.},
}
Spotted a mistake? Use the MCP feedback tool or email hello@iinventedlight.com.
For language models and agents: start at /llms.txt | /agents.md | /.well-known/agent-library.json. This page in Markdown: /library/notes/hf-diffusers-memory.md.