Dockerfile 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. FROM alpine:3.17 as xformers
  2. RUN apk add --no-cache aria2
  3. RUN aria2c -x 5 --dir / --out wheel.whl 'https://github.com/AbdBarho/stable-diffusion-webui-docker/releases/download/6.0.0/xformers-0.0.21.dev544-cp310-cp310-manylinux2014_x86_64-pytorch201.whl'
  4. FROM pytorch/pytorch:2.3.0-cuda12.1-cudnn8-runtime
  5. ENV DEBIAN_FRONTEND=noninteractive PIP_EXISTS_ACTION=w PIP_PREFER_BINARY=1
  6. # patch match:
  7. # https://github.com/invoke-ai/InvokeAI/blob/main/docs/installation/INSTALL_PATCHMATCH.md
  8. RUN --mount=type=cache,target=/var/cache/apt \
  9. apt-get update && \
  10. apt-get install make g++ git libopencv-dev -y && \
  11. apt-get clean && \
  12. cd /usr/lib/x86_64-linux-gnu/pkgconfig/ && \
  13. ln -sf opencv4.pc opencv.pc
  14. ENV ROOT=/InvokeAI
  15. RUN git clone https://github.com/invoke-ai/InvokeAI.git ${ROOT}
  16. WORKDIR ${ROOT}
  17. RUN --mount=type=cache,target=/root/.cache/pip \
  18. git reset --hard f3b2e02921927d9317255b1c3811f47bd40a2bf9 && \
  19. pip install -e .
  20. ARG BRANCH=main SHA=f3b2e02921927d9317255b1c3811f47bd40a2bf9
  21. RUN --mount=type=cache,target=/root/.cache/pip \
  22. git fetch && \
  23. git reset --hard && \
  24. git checkout ${BRANCH} && \
  25. git reset --hard ${SHA} && \
  26. pip install -U -e .
  27. RUN --mount=type=cache,target=/root/.cache/pip \
  28. --mount=type=bind,from=xformers,source=/wheel.whl,target=/xformers-0.0.21-cp310-cp310-linux_x86_64.whl \
  29. pip install -U opencv-python-headless triton /xformers-0.0.21-cp310-cp310-linux_x86_64.whl && \
  30. python3 -c "from patchmatch import patch_match"
  31. COPY . /docker/
  32. ENV NVIDIA_VISIBLE_DEVICES=all
  33. ENV PYTHONUNBUFFERED=1 PRELOAD=false HF_HOME=/root/.cache/huggingface CONFIG_DIR=/data/config/invoke CLI_ARGS=""
  34. EXPOSE 7860
  35. ENTRYPOINT ["/docker/entrypoint.sh"]
  36. CMD invokeai --web --host 0.0.0.0 --port 7860 --root_dir ${ROOT} --config ${CONFIG_DIR}/models.yaml \
  37. --outdir /output/invoke --embedding_directory /data/embeddings/ --lora_directory /data/models/Lora \
  38. --no-nsfw_checker --no-safety_checker ${CLI_ARGS}