Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Docker support (Tested on RTX3080) + ignoring reproducable files / cache #50

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
models/
Dockerfile
README.md
LICENSE
assets/
*.egg-info
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
models/ldm/text2img-large/
outputs/
src/
__pycache__/
*.egg-info
27 changes: 27 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
FROM nvcr.io/nvidia/pytorch:22.04-py3
MAINTAINER Peter Willemsen <[email protected]>

RUN conda

RUN mkdir -p /opt/ldm_package
COPY ./setup.py /opt/ldm_package
COPY ./ldm /opt/ldm_package/ldm
COPY ./configs /opt/ldm_package/configs
COPY environment.yaml /opt/ldm_package

# For the ldm-dev user
RUN chmod 777 -R /opt/ldm_package

WORKDIR /opt/ldm

# Add dev user
RUN useradd -ms /bin/bash ldm-dev && \
usermod -aG sudo ldm-dev && \
echo '%sudo ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers
USER ldm-dev

RUN conda env create -f /opt/ldm_package/environment.yaml
RUN pip3 install -e /opt/ldm_package
RUN conda run -n ldm pip install pytorch-lightning==1.5

ENTRYPOINT ["conda", "run", "-n", "ldm"]
13 changes: 13 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,19 @@ Furthermore, increasing `ddim_steps` generally also gives higher quality samples
Fast sampling (i.e. low values of `ddim_steps`) while retaining good quality can be achieved by using `--ddim_eta 0.0`.
Faster sampling (i.e. even lower values of `ddim_steps`) while retaining good quality can be achieved by using `--ddim_eta 0.0` and `--plms` (see [Pseudo Numerical Methods for Diffusion Models on Manifolds](https://arxiv.org/abs/2202.09778)).

## Installing on Docker

- Build the image: `docker build . --tag latent-diffusion`
- For text-to-image, download the pre-trained weights (5.7GB):
```
mkdir -p models/ldm/text2img-large/
wget -O models/ldm/text2img-large/model.ckpt https://ommer-lab.com/files/latent-diffusion/nitro/txt2img-f8-large/model.ckpt
```
- Sample with (Make sure to call in the directory of this repo):
```
docker run --name=tmp-diffusion --rm --gpus all -it -v "$(pwd):/opt/ldm" latent-diffusion python /opt/ldm/scripts/txt2img.py --prompt "A large blue whale on a freight ship, vector art" --ddim_eta 0.0 --n_samples 4 --n_iter 4 --scale 5.0 --ddim_steps 50
```

#### Beyond 256²

For certain inputs, simply running the model in a convolutional fashion on larger features than it was trained on
Expand Down