Skip to content

Commit ee9e5bf

Browse files
committed
Docker support (Tested on RTX3080) + ignoring reproducable files / cache
1 parent 8381e5e commit ee9e5bf

File tree

4 files changed

+63
-0
lines changed

4 files changed

+63
-0
lines changed

.dockerignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
models/
2+
Dockerfile
3+
README.md
4+
LICENSE
5+
assets/
6+
*.egg-info

.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
models/text2img-large/
2+
outputs/
3+
src/
4+
__pycache__/
5+
*.egg-info

Dockerfile

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
FROM nvidia/cuda:11.3.1-cudnn8-devel-ubuntu20.04
2+
MAINTAINER Peter Willemsen <peter@codebuffet.co>
3+
RUN echo "Installing dependencies..." && \
4+
apt-get update && \
5+
DEBIAN_FRONTEND=noninteractive apt-get install -y curl wget sudo git build-essential cmake pkg-config liblzma-dev libbz2-dev zlib1g-dev libssl-dev zsh clang && \
6+
apt-get dist-upgrade -y && \
7+
rm -rf /var/lib/apt/lists/*
8+
9+
WORKDIR /src/python
10+
RUN wget https://www.python.org/ftp/python/3.8.5/Python-3.8.5.tgz -O python-src.tar.gz && \
11+
tar xzvf python-src.tar.gz --strip-components=1 && \
12+
rm python-src.tar.gz && \
13+
./configure --enable-optimizations --prefix=/opt/python-3.8.5 && \
14+
make && \
15+
make install && \
16+
rm -rf /src/python
17+
WORKDIR /
18+
ENV PATH="/opt/python-3.8.5/bin:${PATH}"
19+
20+
RUN python3 -m pip install pip==20.3
21+
RUN pip3 install torch==1.10.1+cu113 -f https://download.pytorch.org/whl/cu113/torch_stable.html
22+
RUN pip3 install numpy==1.19.2 torchvision==0.11.2 albumentations==0.4.3 opencv-python==4.1.2.30 pudb==2019.2 imageio==2.9.0 imageio-ffmpeg==0.4.2 pytorch-lightning==1.6.1 omegaconf==2.1.1 test-tube>=0.7.5 streamlit>=0.73.1 einops==0.3.0 torch-fidelity==0.3.0 transformers==4.3.1 -e "git+https://github.com/CompVis/taming-transformers.git@master#egg=taming-transformers" -e "git+https://github.com/openai/CLIP.git@main#egg=clip"
23+
24+
RUN mkdir -p /opt/ldm_package
25+
ADD ./setup.py /opt/ldm_package
26+
ADD ./ldm /opt/ldm_package/ldm
27+
ADD ./configs /opt/ldm_package/configs
28+
RUN pip3 install -e /opt/ldm_package
29+
30+
WORKDIR /opt/ldm
31+
32+
# Add dev user
33+
RUN useradd -ms /bin/zsh ldm-dev && \
34+
usermod -aG sudo ldm-dev && \
35+
echo '%sudo ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers
36+
USER ldm-dev
37+
38+
ENTRYPOINT ["python3"]

README.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,20 @@ As a rule of thumb, higher values of `scale` produce better samples at the cost
5858
Furthermore, increasing `ddim_steps` generally also gives higher quality samples, but returns are diminishing for values > 250.
5959
Fast sampling (i.e. low values of `ddim_steps`) while retaining good quality can be achieved by using `--ddim_eta 0.0`.
6060

61+
## Installing on Docker
62+
63+
- Note: depending on CUDA/GPU version, you might have to change the first line in te Dockerfile or change the torch version being installed.
64+
- Build the image: `docker build . --tag latent-diffusion`
65+
- For text-to-image, download the pre-trained weights (5.7GB):
66+
```
67+
mkdir -p models/ldm/text2img-large/
68+
wget -O models/ldm/text2img-large/model.ckpt https://ommer-lab.com/files/latent-diffusion/nitro/txt2img-f8-large/model.ckpt
69+
```
70+
- Sample with (Make sure to call in the directory of this repo):
71+
```
72+
docker run --name=tmp-diffusion --rm --gpus all -it -v "$(pwd):/opt/ldm" latent-diffusion /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
73+
```
74+
6175
#### Beyond 256²
6276

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

0 commit comments

Comments
 (0)