@@ -47,6 +47,7 @@ RUN --mount=type=cache,id=apt-dev,target=/var/cache/apt \
47
47
python$PYTHON_VERSION-venv \
48
48
openjdk-17-jdk \
49
49
curl \
50
+ git \
50
51
&& rm -rf /var/lib/apt/lists/*
51
52
52
53
# Make the virtual environment and "activating" it by adding it first to the path.
@@ -62,26 +63,29 @@ RUN export USE_CUDA=1
62
63
63
64
ARG CUDA_VERSION=""
64
65
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 \
67
71
if echo "$BASE_IMAGE" | grep -q "cuda:" ; then \
68
72
# Install CUDA version specific binary when CUDA version is specified as a build arg
69
73
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
72
76
else \
73
- python -m pip install --no-cache-dir torch torchvision ; \
77
+ python ./ts_scripts/install_dependencies.py ; \
74
78
fi; \
75
- python -m pip install --no-cache-dir -r https://raw.githubusercontent.com/pytorch/serve/master/requirements/common.txt; \
76
79
# Install the CPU binary
77
80
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 ; \
79
82
fi
80
83
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
82
86
83
87
# Final image for production
84
- FROM ${BASE_IMAGE} AS runtime-image
88
+ FROM ${BASE_IMAGE} AS runtime-image
85
89
# Re-state ARG PYTHON_VERSION to make it active in this build-stage (uses default define at the top)
86
90
ARG PYTHON_VERSION
87
91
ENV PYTHONUNBUFFERED TRUE
0 commit comments