Installation

This guide will walk you through setting up the denoising-diffusion-pytorch library in your environment.

Standard Installation

For most users, installing the package from PyPI is the recommended approach.

$ pip install denoising_diffusion_pytorch

Dependencies

The library relies on several other packages. pip will handle installing these for you. The core dependencies are:

  • accelerate
  • einops
  • ema-pytorch>=0.4.2
  • numpy
  • pillow
  • pytorch-fid
  • scipy
  • torch>=2.0
  • torchvision
  • tqdm

Note: This package requires PyTorch version 2.0 or higher, especially if you plan to use features like Flash Attention.

Developer Installation

If you plan to modify the source code or contribute to the project, you should install it in editable mode. First, clone the repository:

git clone https://github.com/lucidrains/denoising-diffusion-pytorch.git
cd denoising-diffusion-pytorch

Then, install the package in editable mode:

pip install -e .

This will link the installed package to your local repository, so any changes you make to the source code will be immediately reflected in your environment.

Multi-GPU Training Setup

The Trainer class is integrated with 🤗 accelerate for seamless multi-GPU and distributed training. To configure accelerate for your machine, run the following command in your project's root directory:

accelerate config

This will launch an interactive wizard that asks you questions about your setup (e.g., number of GPUs, mixed precision). Once configured, you can launch your training script using:

accelerate launch your_training_script.py

This handles all the boilerplate for distributed training, allowing you to scale your experiments effortlessly.