FROM alpine/git:2.36.2 AS download
COPY clone.sh /clone.sh
# 2024-06-20
RUN . /clone.sh stable-diffusion-stability-ai https://github.com/Stability-AI/stablediffusion.git cf1d67a6fd5ea1aa600c4df58e5b47da45f6bdbf \
&& rm -rf assets data/**/*.png data/**/*.jpg data/**/*.gif
RUN . /clone.sh CodeFormer https://github.com/sczhou/CodeFormer.git 8392d0334956108ab53d9439c4b9fc9c4af0d66d \
#RUN . /clone.sh CodeFormer https://github.com/sczhou/CodeFormer.git c5b4593074ba6214284d6acd5f1719b6c5d739af \
&& rm -rf assets inputs
RUN . /clone.sh BLIP https://github.com/salesforce/BLIP.git 3a29b7410476bf5f2ba0955827390eb6ea1f4f9d
#RUN . /clone.sh BLIP https://github.com/salesforce/BLIP.git 48211a1594f1321b00f14c9f7a5b4813144b2fb9
RUN . /clone.sh k-diffusion https://github.com/crowsonkb/k-diffusion.git 21d12c91ad4550e8fcf3308ff9fe7116b3f19a08
#RUN . /clone.sh k-diffusion https://github.com/crowsonkb/k-diffusion.git 6ab5146d4a5ef63901326489f31f1d8e7dd36b48
RUN . /clone.sh clip-interrogator https://github.com/pharmapsychotic/clip-interrogator bc07ce62c179d3aab3053a623d96a071101d11cb
#RUN . /clone.sh clip-interrogator https://github.com/pharmapsychotic/clip-interrogator 2cf03aaf6e704197fd0dae7c7f96aa59cf1b11c9
RUN . /clone.sh generative-models https://github.com/Stability-AI/generative-models 863665548f95ff827273948766a3f732ab01bc49
RUN . /clone.sh stable-diffusion-webui-assets https://github.com/AUTOMATIC1111/stable-diffusion-webui-assets 6f7db241d2f8ba7457bac5ca9753331f0c266917
FROM pytorch/pytorch:2.4.0-cuda12.4-cudnn9-runtime
ENV DEBIAN_FRONTEND=noninteractive PIP_PREFER_BINARY=1
RUN --mount=type=cache,target=/var/cache/apt \
apt-get update && \
# we need those
apt-get install -y fonts-dejavu-core rsync git jq moreutils aria2 python3.11 python3-pip \
# extensions needs those
ffmpeg libglfw3-dev libgles2-mesa-dev pkg-config libcairo2 libcairo2-dev build-essential
RUN ln -s /usr/bin/python3.11 /usr/bin/python
WORKDIR /
RUN --mount=type=cache,target=/root/.cache/pip \
python -m pip install pyngrok xformers dctorch torchvision \
git+https://github.com/TencentARC/GFPGAN.git@7552a7791caad982045a7bbe5634bbf1cd5c8679 \
git+https://github.com/openai/CLIP.git@dcba3cb2e2827b402d2701e7e1c7d9fed8a20ef1 \
git+https://github.com/mlfoundations/[email protected]
# there seems to be a memory leak (or maybe just memory not being freed fast enough) that is fixed by this version of malloc
# maybe move this up to the dependencies list.
RUN --mount=type=cache,target=/var/cache/apt \
apt-get -y install libgoogle-perftools-dev && apt-get clean
ENV LD_PRELOAD=libtcmalloc.so
# pre-installs for extensions
RUN --mount=type=cache,target=/root/.cache/pip \
python -m pip install insightface wandb ffmpeg ffmpeg-python yt-dlp \
torchvision==0.19.0 tensorflow_io tensorflow protobuf transformers \
ultralytics>=8.2.0 mediapipe>=0.10.13
# 2024/07/27 1.10.1
ENV A1111_BRANCH=master
ENV A1111_COMMIT=82a973c04367123ae98bd9abdf80d9eda9b910e2
ENV A1111_GIT=https://github.com/AUTOMATIC1111/stable-diffusion-webui.git
# 2024/07/20
#ENV A1111_COMMIT=9f5a98d5766b4ac233d916fe8b02ea16b8b2c259
RUN --mount=type=cache,target=/root/.cache/pip \
git clone ${A1111_GIT} -b ${A1111_BRANCH} stable-diffusion-webui && \
cd stable-diffusion-webui && \
git pull origin ${A1111_BRANCH} && \
git reset --hard ${A1111_COMMIT} && \
python -m pip install -r requirements_versions.txt
ENV ROOT=/stable-diffusion-webui
COPY --from=download /repositories/ ${ROOT}/repositories/
RUN mkdir ${ROOT}/interrogate && cp ${ROOT}/repositories/clip-interrogator/clip_interrogator/data/* ${ROOT}/interrogate
RUN --mount=type=cache,target=/root/.cache/pip \
python -m pip install -r ${ROOT}/repositories/CodeFormer/requirements.txt
RUN \
# mv ${ROOT}/style.css ${ROOT}/user.css && \
# one of the ugliest hacks I ever wrote \
sed -i 's/in_app_dir = .*/in_app_dir = True/g' \
/opt/conda/lib/python3.11/site-packages/gradio/routes.py && \
git config --global --add safe.directory '*'
RUN mkdir /root/.cache && ln -s /models/huggingface /root/.cache/huggingface
RUN rm -rf ${ROOT}/models && ln -s /models ${ROOT}/models
COPY . /docker
WORKDIR ${ROOT}
ENV NVIDIA_VISIBLE_DEVICES=all
ENV CLI_ARGS=""
EXPOSE 7860
ENTRYPOINT ["/docker/entrypoint.sh"]
CMD python -u webui.py --listen --port 7860 ${CLI_ARGS}
Comments
0 B
|👍
/👎
0 B
|👍
/👎