Advertisement
zefie

auto1111 dockerfile

Feb 8th, 2025
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
YAML 4.34 KB | None | 0 0
  1. FROM alpine/git:2.36.2 AS download
  2.  
  3. COPY clone.sh /clone.sh
  4.  
  5. # 2024-06-20
  6.  
  7. RUN . /clone.sh stable-diffusion-stability-ai https://github.com/Stability-AI/stablediffusion.git cf1d67a6fd5ea1aa600c4df58e5b47da45f6bdbf \
  8.   && rm -rf assets data/**/*.png data/**/*.jpg data/**/*.gif
  9.  
  10. RUN . /clone.sh CodeFormer https://github.com/sczhou/CodeFormer.git 8392d0334956108ab53d9439c4b9fc9c4af0d66d \
  11. #RUN . /clone.sh CodeFormer https://github.com/sczhou/CodeFormer.git c5b4593074ba6214284d6acd5f1719b6c5d739af \
  12.   && rm -rf assets inputs
  13.  
  14. RUN . /clone.sh BLIP https://github.com/salesforce/BLIP.git 3a29b7410476bf5f2ba0955827390eb6ea1f4f9d
  15. #RUN . /clone.sh BLIP https://github.com/salesforce/BLIP.git 48211a1594f1321b00f14c9f7a5b4813144b2fb9
  16.  
  17. RUN . /clone.sh k-diffusion https://github.com/crowsonkb/k-diffusion.git 21d12c91ad4550e8fcf3308ff9fe7116b3f19a08
  18. #RUN . /clone.sh k-diffusion https://github.com/crowsonkb/k-diffusion.git 6ab5146d4a5ef63901326489f31f1d8e7dd36b48
  19.  
  20. RUN . /clone.sh clip-interrogator https://github.com/pharmapsychotic/clip-interrogator bc07ce62c179d3aab3053a623d96a071101d11cb
  21. #RUN . /clone.sh clip-interrogator https://github.com/pharmapsychotic/clip-interrogator 2cf03aaf6e704197fd0dae7c7f96aa59cf1b11c9
  22.  
  23. RUN . /clone.sh generative-models https://github.com/Stability-AI/generative-models 863665548f95ff827273948766a3f732ab01bc49
  24. RUN . /clone.sh stable-diffusion-webui-assets https://github.com/AUTOMATIC1111/stable-diffusion-webui-assets 6f7db241d2f8ba7457bac5ca9753331f0c266917
  25.  
  26. FROM pytorch/pytorch:2.4.0-cuda12.4-cudnn9-runtime
  27.  
  28. ENV DEBIAN_FRONTEND=noninteractive PIP_PREFER_BINARY=1
  29.  
  30. RUN --mount=type=cache,target=/var/cache/apt \
  31.   apt-get update && \
  32.   # we need those
  33.   apt-get install -y fonts-dejavu-core rsync git jq moreutils aria2 python3.11 python3-pip \
  34.   # extensions needs those
  35.   ffmpeg libglfw3-dev libgles2-mesa-dev pkg-config libcairo2 libcairo2-dev build-essential
  36.  
  37. RUN ln -s /usr/bin/python3.11 /usr/bin/python
  38.  
  39. WORKDIR /
  40.  
  41. RUN --mount=type=cache,target=/root/.cache/pip \
  42.   python -m pip install pyngrok xformers dctorch torchvision \
  43.   git+https://github.com/TencentARC/GFPGAN.git@7552a7791caad982045a7bbe5634bbf1cd5c8679 \
  44.   git+https://github.com/openai/CLIP.git@dcba3cb2e2827b402d2701e7e1c7d9fed8a20ef1 \
  45.   git+https://github.com/mlfoundations/open_clip.git@v2.26.1
  46.  
  47. # there seems to be a memory leak (or maybe just memory not being freed fast enough) that is fixed by this version of malloc
  48. # maybe move this up to the dependencies list.
  49. RUN --mount=type=cache,target=/var/cache/apt \
  50.   apt-get -y install libgoogle-perftools-dev && apt-get clean
  51.  
  52. ENV LD_PRELOAD=libtcmalloc.so
  53.  
  54. # pre-installs for extensions
  55.  
  56. RUN --mount=type=cache,target=/root/.cache/pip \
  57.   python -m pip install insightface wandb ffmpeg ffmpeg-python yt-dlp \
  58.   torchvision==0.19.0 tensorflow_io tensorflow protobuf transformers \
  59.   ultralytics>=8.2.0 mediapipe>=0.10.13
  60.  
  61. # 2024/07/27 1.10.1
  62. ENV A1111_BRANCH=master
  63. ENV A1111_COMMIT=82a973c04367123ae98bd9abdf80d9eda9b910e2
  64. ENV A1111_GIT=https://github.com/AUTOMATIC1111/stable-diffusion-webui.git
  65.  
  66. # 2024/07/20
  67. #ENV A1111_COMMIT=9f5a98d5766b4ac233d916fe8b02ea16b8b2c259
  68.  
  69. RUN --mount=type=cache,target=/root/.cache/pip \
  70.   git clone ${A1111_GIT} -b ${A1111_BRANCH} stable-diffusion-webui && \
  71.   cd stable-diffusion-webui && \
  72.   git pull origin ${A1111_BRANCH} && \
  73.   git reset --hard ${A1111_COMMIT} && \
  74.   python -m pip install -r requirements_versions.txt
  75.  
  76. ENV ROOT=/stable-diffusion-webui
  77.  
  78. COPY --from=download /repositories/ ${ROOT}/repositories/
  79. RUN mkdir ${ROOT}/interrogate && cp ${ROOT}/repositories/clip-interrogator/clip_interrogator/data/* ${ROOT}/interrogate
  80.  
  81. RUN --mount=type=cache,target=/root/.cache/pip \
  82.   python -m pip install -r ${ROOT}/repositories/CodeFormer/requirements.txt
  83.  
  84. RUN \
  85.   # mv ${ROOT}/style.css ${ROOT}/user.css && \
  86.   # one of the ugliest hacks I ever wrote \
  87.   sed -i 's/in_app_dir = .*/in_app_dir = True/g' \
  88.   /opt/conda/lib/python3.11/site-packages/gradio/routes.py && \
  89.   git config --global --add safe.directory '*'
  90.  
  91. RUN mkdir /root/.cache && ln -s /models/huggingface /root/.cache/huggingface
  92. RUN rm -rf ${ROOT}/models && ln -s /models ${ROOT}/models
  93.  
  94. COPY . /docker
  95.  
  96. WORKDIR ${ROOT}
  97. ENV NVIDIA_VISIBLE_DEVICES=all
  98. ENV CLI_ARGS=""
  99. EXPOSE 7860
  100. ENTRYPOINT ["/docker/entrypoint.sh"]
  101. CMD python -u webui.py --listen --port 7860 ${CLI_ARGS}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement