Dockerfile 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  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/5.0.0/xformers-0.0.17.dev449-cp310-cp310-manylinux2014_x86_64.whl'
  4. FROM python:3.10-slim
  5. ENV DEBIAN_FRONTEND=noninteractive PIP_EXISTS_ACTION=w PIP_PREFER_BINARY=1
  6. RUN --mount=type=cache,target=/root/.cache/pip pip install torch==1.13.1+cu117 torchvision --extra-index-url https://download.pytorch.org/whl/cu117
  7. # patch match:
  8. # https://github.com/invoke-ai/InvokeAI/blob/main/docs/installation/INSTALL_PATCHMATCH.md
  9. RUN --mount=type=cache,target=/var/cache/apt \
  10. apt-get update && \
  11. apt-get install make g++ git libopencv-dev -y && \
  12. apt-get clean && \
  13. cd /usr/lib/x86_64-linux-gnu/pkgconfig/ && \
  14. ln -sf opencv4.pc opencv.pc
  15. ENV ROOT=/InvokeAI
  16. RUN git clone https://github.com/invoke-ai/InvokeAI.git ${ROOT}
  17. WORKDIR ${ROOT}
  18. RUN --mount=type=cache,target=/root/.cache/pip \
  19. git reset --hard 4463124bddd221c333d4c70e73aa2949ad35453d && \
  20. pip install .
  21. ARG BRANCH=main SHA=50eb02f68be912276a9c106d5e8038a5671a0386
  22. RUN --mount=type=cache,target=/root/.cache/pip \
  23. git fetch && \
  24. git reset --hard && \
  25. git checkout ${BRANCH} && \
  26. git reset --hard ${SHA} && \
  27. pip install -U .
  28. RUN --mount=type=cache,target=/root/.cache/pip \
  29. --mount=type=bind,from=xformers,source=/wheel.whl,target=/xformers-0.0.17-cp310-cp310-linux_x86_64.whl \
  30. pip install -U opencv-python-headless triton /xformers-0.0.17-cp310-cp310-linux_x86_64.whl && \
  31. python3 -c "from patchmatch import patch_match"
  32. COPY . /docker/
  33. ENV NVIDIA_DRIVER_CAPABILITIES=compute,utility
  34. ENV NVIDIA_VISIBLE_DEVICES=all
  35. ENV PYTHONUNBUFFERED=1 PRELOAD=false HF_HOME=/root/.cache/huggingface CONFIG_DIR=/data/config/invoke CLI_ARGS=""
  36. EXPOSE 7860
  37. ENTRYPOINT ["/docker/entrypoint.sh"]
  38. CMD invokeai --web --host 0.0.0.0 --port 7860 --root_dir ${ROOT} --config ${CONFIG_DIR}/models.yaml --outdir /output/invoke ${CLI_ARGS}
  39. # TODO: make sure the config is persisted between sessions