Skip to content

Commit ad989c2

Browse files
authored
Create Dockerfile.gtx
1 parent cc12d0f commit ad989c2

File tree

1 file changed

+84
-0
lines changed

1 file changed

+84
-0
lines changed

services/reforge/Dockerfile.gtx

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
FROM alpine/git:2.36.2 AS download
2+
3+
COPY clone.sh /clone.sh
4+
5+
RUN . /clone.sh stable-diffusion-stability-ai https://github.com/Stability-AI/stablediffusion.git cf1d67a6fd5ea1aa600c4df58e5b47da45f6bdbf \
6+
&& rm -rf assets data/**/*.png data/**/*.jpg data/**/*.gif
7+
8+
RUN . /clone.sh CodeFormer https://github.com/sczhou/CodeFormer.git c5b4593074ba6214284d6acd5f1719b6c5d739af \
9+
&& rm -rf assets inputs
10+
11+
RUN . /clone.sh BLIP https://github.com/salesforce/BLIP.git 48211a1594f1321b00f14c9f7a5b4813144b2fb9
12+
RUN . /clone.sh k-diffusion https://github.com/crowsonkb/k-diffusion.git ab527a9a6d347f364e3d185ba6d714e22d80cb3c
13+
RUN . /clone.sh clip-interrogator https://github.com/pharmapsychotic/clip-interrogator 2cf03aaf6e704197fd0dae7c7f96aa59cf1b11c9
14+
RUN . /clone.sh generative-models https://github.com/Stability-AI/generative-models 45c443b316737a4ab6e40413d7794a7f5657c19f
15+
RUN . /clone.sh stable-diffusion-webui-assets https://github.com/AUTOMATIC1111/stable-diffusion-webui-assets.git 6f7db241d2f8ba7457bac5ca9753331f0c266917
16+
17+
18+
FROM pytorch/pytorch:2.3.1-cuda12.1-cudnn8-runtime
19+
20+
ENV DEBIAN_FRONTEND=noninteractive PIP_PREFER_BINARY=1
21+
22+
RUN --mount=type=cache,target=/var/cache/apt \
23+
apt-get update && \
24+
# we need those
25+
apt-get install -y fonts-dejavu-core rsync git jq moreutils aria2 \
26+
# extensions needs those
27+
ffmpeg libglfw3-dev libgles2-mesa-dev pkg-config libcairo2 libcairo2-dev build-essential
28+
29+
30+
WORKDIR /
31+
RUN --mount=type=cache,target=/root/.cache/pip \
32+
git clone https://github.com/Panchovix/stable-diffusion-webui-reForge.git /stable-diffusion-webui-reforge && \
33+
cd stable-diffusion-webui-reforge && \
34+
sed -i '/torch/d' requirements_versions.txt && \
35+
pip install -r requirements_versions.txt
36+
37+
ENV ROOT=/stable-diffusion-webui-reforge
38+
39+
COPY --from=download /repositories/ ${ROOT}/repositories/
40+
RUN mkdir ${ROOT}/interrogate && cp ${ROOT}/repositories/clip-interrogator/clip_interrogator/data/* ${ROOT}/interrogate
41+
RUN --mount=type=cache,target=/root/.cache/pip \
42+
pip install -r ${ROOT}/repositories/CodeFormer/requirements.txt
43+
44+
# Clone and copy huggingface_guess module
45+
RUN git clone https://github.com/lllyasviel/huggingface_guess.git /tmp/huggingface_guess && \
46+
cp -r /tmp/huggingface_guess/huggingface_guess ${ROOT}/huggingface_guess
47+
48+
# Ensure torchvision is correctly installed
49+
RUN --mount=type=cache,target=/root/.cache/pip \
50+
pip install torchvision==0.18.1
51+
52+
RUN --mount=type=cache,target=/root/.cache/pip \
53+
pip install pyngrok xformers==0.0.27 pytorch_lightning==1.6.5 torchdiffeq torchsde \
54+
git+https://github.com/TencentARC/GFPGAN.git@8d2447a2d918f8eba5a4a01463fd48e45126a379 \
55+
git+https://github.com/openai/CLIP.git@d50d76daa670286dd6cacf3bcd80b5e4823fc8e1 \
56+
git+https://github.com/mlfoundations/open_clip.git@v2.20.0
57+
# there seems to be a memory leak (or maybe just memory not being freed fast enough) that is fixed by this version of malloc
58+
# maybe move this up to the dependencies list.
59+
RUN apt-get -y install libgoogle-perftools-dev && apt-get clean
60+
ENV LD_PRELOAD=libtcmalloc.so
61+
62+
COPY . /docker
63+
RUN pip install pydantic==1.10.21
64+
65+
RUN if [ -d "/opt/conda/lib/python3.10" ]; then \
66+
echo Python 3.10 detected; \
67+
sed -i 's/in_app_dir = .*/in_app_dir = True/g' /opt/conda/lib/python3.10/site-packages/gradio/routes.py ;\
68+
elif [ -d "/opt/conda/lib/python3.11" ]; then \
69+
echo Python 3.11 detected; \
70+
sed -i 's/in_app_dir = .*/in_app_dir = True/g' /opt/conda/lib/python3.11/site-packages/gradio/routes.py ;\
71+
fi && \
72+
# mv ${ROOT}/style.css ${ROOT}/user.css && \
73+
# one of the ugliest hacks I ever wrote \
74+
# updated from 3.10.to 3.11
75+
git config --global --add safe.directory '*'
76+
77+
78+
79+
WORKDIR ${ROOT}
80+
ENV NVIDIA_VISIBLE_DEVICES=all
81+
ENV CLI_ARGS=""
82+
EXPOSE 7860
83+
ENTRYPOINT ["/docker/entrypoint.sh"]
84+
CMD python -u webui.py --listen --port 7860 ${CLI_ARGS}

0 commit comments

Comments
 (0)