11# Must use a Cuda version 11+
2- FROM pytorch/pytorch:1.11.0-cuda11.3-cudnn8-devel
3-
4- RUN mkdir /api
5- WORKDIR /api
6-
7- RUN apt-key adv --keyserver keyserver.ubuntu.com --recv-keys A4B469963BF863CC
2+ FROM pytorch/pytorch:1.11.0-cuda11.3-cudnn8-devel as base
83ENV DEBIAN_FRONTEND=noninteractive
9-
10- # Install git and OpenCV
4+ RUN mkdir -p /root/.cache/pip
5+ COPY root-cache/pip /root/.cache/pip
6+ RUN apt-key adv --keyserver keyserver.ubuntu.com --recv-keys A4B469963BF863CC
117RUN apt-get update && apt-get install -yqq git
128
13- WORKDIR /
14-
15- COPY root-cache/. /root/.cache
9+ FROM base AS patchmatch
10+ ARG USE_PATCHMATCH=0
11+ WORKDIR /tmp
12+ COPY scripts/patchmatch-setup.sh .
13+ RUN sh patchmatch-setup.sh
1614
17- # Compile PyPatchMatch
18- RUN apt-get install -yqq libopencv-dev python3-opencv
19- WORKDIR /PyPatchMatch
20- ADD PyPatchMatch .
21- RUN make
15+ FROM base as output
16+ RUN mkdir /api
17+ WORKDIR /api
2218
2319# Install python packages
2420RUN pip3 install --upgrade pip
@@ -56,6 +52,9 @@ ENV PIPELINE=${PIPELINE}
5652
5753# If set, it will be downloaded and converted to diffusers format, and
5854# saved in a directory with same MODEL_ID name to be loaded by diffusers.
55+ COPY root-cache/huggingface /root/.cache/huggingface
56+ COPY root-cache/checkpoints /root/.cache/checkpoints
57+ RUN du -sh /root/.cache/*
5958ARG CHECKPOINT_URL=""
6059ENV CHECKPOINT_URL=${CHECKPOINT_URL}
6160ADD download-checkpoint.py .
@@ -70,6 +69,11 @@ ADD loadModel.py .
7069ADD download.py .
7170RUN python3 download.py
7271
72+ # Deps for RUNNING (not building) earlier options
73+ ARG USE_PATCHMATCH=0
74+ RUN if [ "$USE_PATCHMATCH" = "1" ] ; then apt-get install -yqq python3-opencv ; fi
75+ COPY --from=patchmatch /tmp/PyPatchMatch PyPatchMatch
76+
7377# Add your custom app code, init() and inference()
7478ADD send.py .
7579ADD app.py .
0 commit comments