Skip to content

Commit 35fb574

Browse files
authored
Issues/fix docker dependencies (#2340)
* re-run kserve build because of runner issue * Fixes missing dependencies * added depth 1 to reduce clone size by 50 MB
1 parent 8ea1dab commit 35fb574

File tree

1 file changed

+13
-9
lines changed

1 file changed

+13
-9
lines changed

Diff for: docker/Dockerfile

+13-9
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ RUN --mount=type=cache,id=apt-dev,target=/var/cache/apt \
4747
python$PYTHON_VERSION-venv \
4848
openjdk-17-jdk \
4949
curl \
50+
git \
5051
&& rm -rf /var/lib/apt/lists/*
5152

5253
# Make the virtual environment and "activating" it by adding it first to the path.
@@ -62,26 +63,29 @@ RUN export USE_CUDA=1
6263

6364
ARG CUDA_VERSION=""
6465

65-
RUN TORCH_VER=$(curl --silent --location https://pypi.org/pypi/torch/json | python -c "import sys, json, pkg_resources; releases = json.load(sys.stdin)['releases']; print(sorted(releases, key=pkg_resources.parse_version)[-1])") && \
66-
TORCH_VISION_VER=$(curl --silent --location https://pypi.org/pypi/torchvision/json | python -c "import sys, json, pkg_resources; releases = json.load(sys.stdin)['releases']; print(sorted(releases, key=pkg_resources.parse_version)[-1])") && \
66+
RUN git clone --depth 1 https://github.com/pytorch/serve.git
67+
68+
WORKDIR "serve"
69+
70+
RUN \
6771
if echo "$BASE_IMAGE" | grep -q "cuda:"; then \
6872
# Install CUDA version specific binary when CUDA version is specified as a build arg
6973
if [ "$CUDA_VERSION" ]; then \
70-
python -m pip install --no-cache-dir torch==$TORCH_VER+$CUDA_VERSION torchvision==$TORCH_VISION_VER+$CUDA_VERSION -f https://download.pytorch.org/whl/torch_stable.html; \
71-
# Install the binary with the latest CUDA version support
74+
python ./ts_scripts/install_dependencies.py --cuda $CUDA_VERSION; \
75+
# Install the binary with the latest CPU image on a CUDA base image
7276
else \
73-
python -m pip install --no-cache-dir torch torchvision; \
77+
python ./ts_scripts/install_dependencies.py; \
7478
fi; \
75-
python -m pip install --no-cache-dir -r https://raw.githubusercontent.com/pytorch/serve/master/requirements/common.txt; \
7679
# Install the CPU binary
7780
else \
78-
python -m pip install --no-cache-dir torch==$TORCH_VER+cpu torchvision==$TORCH_VISION_VER+cpu -f https://download.pytorch.org/whl/torch_stable.html; \
81+
python ./ts_scripts/install_dependencies.py; \
7982
fi
8083

81-
RUN python -m pip install --no-cache-dir captum torchtext torchserve torch-model-archiver pyyaml
84+
# Make sure latest version of torchserve is uploaded before running this
85+
RUN python -m pip install --no-cache-dir torchserve torch-model-archiver torch-workflow-archiver
8286

8387
# Final image for production
84-
FROM ${BASE_IMAGE} AS runtime-image
88+
FROM ${BASE_IMAGE} AS runtime-image
8589
# Re-state ARG PYTHON_VERSION to make it active in this build-stage (uses default define at the top)
8690
ARG PYTHON_VERSION
8791
ENV PYTHONUNBUFFERED TRUE

0 commit comments

Comments
 (0)