forked from pytorch/serve
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
58 additions
and
59 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -41,7 +41,6 @@ RUN --mount=type=cache,sharing=locked,id=apt-dev,target=/var/cache/apt \ | |
apt-get upgrade -y && \ | ||
apt-get install software-properties-common -y && \ | ||
add-apt-repository -y ppa:deadsnakes/ppa && \ | ||
apt remove -y python-pip python3-pip && \ | ||
DEBIAN_FRONTEND=noninteractive apt-get install --no-install-recommends -y \ | ||
ca-certificates \ | ||
g++ \ | ||
|
@@ -51,6 +50,7 @@ RUN --mount=type=cache,sharing=locked,id=apt-dev,target=/var/cache/apt \ | |
python$PYTHON_VERSION-venv \ | ||
openjdk-17-jdk \ | ||
curl \ | ||
wget \ | ||
git \ | ||
&& rm -rf /var/lib/apt/lists/* | ||
|
||
|
@@ -62,17 +62,6 @@ ENV PATH="/home/venv/bin:$PATH" | |
|
||
ARG USE_ROCM_VERSION="" | ||
|
||
RUN --mount=type=cache,id=apt-dev,target=/var/cache/apt \ | ||
if [ -n "$USE_ROCM_VERSION" ]; then \ | ||
apt-get update \ | ||
&& curl -O https://repo.radeon.com/amdgpu-install/6.2.2/ubuntu/noble/amdgpu-install_6.2.60202-1_all.deb \ | ||
&& DEBIAN_FRONTEND=noninteractive apt-get install -y ./amdgpu-install_6.2.60202-1_all.deb \ | ||
&& apt-get update \ | ||
&& apt-get install --no-install-recommends -y amdgpu-dkms rocm; \ | ||
else \ | ||
echo "Skip ROCm installation"; \ | ||
fi | ||
|
||
COPY ./ serve | ||
|
||
RUN \ | ||
|
@@ -81,45 +70,53 @@ RUN \ | |
git clone --recursive $REPO_URL -b $BRANCH_NAME /serve; \ | ||
fi | ||
|
||
|
||
WORKDIR "/serve" | ||
|
||
RUN cp docker/dockerd-entrypoint.sh /usr/local/bin/dockerd-entrypoint.sh | ||
|
||
RUN --mount=type=cache,sharing=locked,id=apt-dev,target=/var/cache/apt \ | ||
if [ -n "$USE_ROCM_VERSION" ]; then \ | ||
apt-get update \ | ||
&& wget https://repo.radeon.com/amdgpu-install/6.2.2/ubuntu/noble/amdgpu-install_6.2.60202-1_all.deb \ | ||
&& DEBIAN_FRONTEND=noninteractive apt-get install -y ./amdgpu-install_6.2.60202-1_all.deb \ | ||
&& apt-get update \ | ||
&& apt-get install --no-install-recommends -y amdgpu-dkms rocm; \ | ||
else \ | ||
echo "Skip ROCm installation"; \ | ||
fi | ||
|
||
RUN \ | ||
# Install ROCm version specific binary when ROCm version is specified as a build arg | ||
if [ "$USE_ROCM_VERSION" ]; then \ | ||
python ./ts_scripts/install_dependencies.py --rocm $USE_ROCM_VERSION \ | ||
&& python -m pip install /opt/rocm/share/amd_smi; \ | ||
python$PYTHON_VERSION ./ts_scripts/install_dependencies.py --rocm $USE_ROCM_VERSION; \ | ||
# Install the binary with the latest CPU image on a ROCm base image | ||
else \ | ||
python ./ts_scripts/install_dependencies.py;\ | ||
python$PYTHON_VERSION ./ts_scripts/install_dependencies.py;\ | ||
fi; | ||
|
||
# Make sure latest version of torchserve is uploaded before running this | ||
RUN \ | ||
if echo "$BUILD_FROM_SRC" | grep -q "true"; then \ | ||
python -m pip install -r requirements/developer.txt \ | ||
&& python ts_scripts/install_from_src.py;\ | ||
python$PYTHON_VERSION -m pip install -r requirements/developer.txt \ | ||
&& python$PYTHON_VERSION ts_scripts/install_from_src.py;\ | ||
elif echo "$BUILD_NIGHTLY" | grep -q "false"; then \ | ||
python -m pip install --no-cache-dir torchserve torch-model-archiver torch-workflow-archiver;\ | ||
python$PYTHON_VERSION -m pip install --no-cache-dir torchserve torch-model-archiver torch-workflow-archiver;\ | ||
else \ | ||
python -m pip install --no-cache-dir torchserve-nightly torch-model-archiver-nightly torch-workflow-archiver-nightly;\ | ||
python$PYTHON_VERSION -m pip install --no-cache-dir torchserve-nightly torch-model-archiver-nightly torch-workflow-archiver-nightly;\ | ||
fi | ||
|
||
# Final image for production | ||
FROM ${BASE_IMAGE} AS production-image | ||
# Re-state ARG PYTHON_VERSION to make it active in this build-stage (uses default define at the top) | ||
ARG PYTHON_VERSION | ||
ARG USE_ROCM_VERSION | ||
ENV PYTHONUNBUFFERED TRUE | ||
ARG USE_ROCM_VERSION | ||
|
||
RUN --mount=type=cache,sharing=locked,target=/var/cache/apt \ | ||
apt-get update && \ | ||
apt-get upgrade -y && \ | ||
apt-get install software-properties-common -y && \ | ||
add-apt-repository ppa:deadsnakes/ppa -y && \ | ||
apt remove -y python-pip python3-pip && \ | ||
DEBIAN_FRONTEND=noninteractive apt-get install --no-install-recommends -y \ | ||
python$PYTHON_VERSION \ | ||
python3-setuptools \ | ||
|
@@ -129,13 +126,15 @@ RUN --mount=type=cache,sharing=locked,target=/var/cache/apt \ | |
# https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1009905 | ||
openjdk-17-jdk \ | ||
build-essential \ | ||
wget \ | ||
&& rm -rf /var/lib/apt/lists/* \ | ||
&& cd /tmp | ||
|
||
RUN --mount=type=bind,from=compile-image,target=/mnt \ | ||
if [ "$USE_ROCM_VERSION" ]; then \ | ||
RUN --mount=type=cache,sharing=locked,id=apt-dev,target=/var/cache/apt \ | ||
if [ -n "$USE_ROCM_VERSION" ]; then \ | ||
apt-get update \ | ||
&& DEBIAN_FRONTEND=noninteractive apt-get install -y ./mnt/amdgpu-install_6.2.60202-1_all.deb \ | ||
&& wget https://repo.radeon.com/amdgpu-install/6.2.2/ubuntu/noble/amdgpu-install_6.2.60202-1_all.deb \ | ||
&& DEBIAN_FRONTEND=noninteractive apt-get install -y ./amdgpu-install_6.2.60202-1_all.deb \ | ||
&& apt-get update \ | ||
&& apt-get install --no-install-recommends -y amdgpu-dkms rocm; \ | ||
else \ | ||
|
@@ -149,13 +148,10 @@ COPY --chown=model-server --from=compile-image /home/venv /home/venv | |
COPY --from=compile-image /usr/local/bin/dockerd-entrypoint.sh /usr/local/bin/dockerd-entrypoint.sh | ||
ENV PATH="/home/venv/bin:$PATH" | ||
|
||
COPY --from=compile-image /opt/rocm/share/amd_smi /opt/rocm/share/amd_smi | ||
|
||
RUN \ | ||
if [ "$USE_ROCM_VERSION" ]; then \ | ||
python -m pip install /opt/rocm/share/amd_smi; \ | ||
else \ | ||
echo "Skip ROCm installation"; \ | ||
if [ -n "$USE_ROCM_VERSION" ]; then \ | ||
python$PYTHON_VERSION -m pip install -U pip setuptools \ | ||
&& python -m pip install /opt/rocm/share/amd_smi; \ | ||
fi | ||
|
||
RUN chmod +x /usr/local/bin/dockerd-entrypoint.sh \ | ||
|
@@ -177,14 +173,14 @@ FROM ${BASE_IMAGE} AS ci-image | |
# Re-state ARG PYTHON_VERSION to make it active in this build-stage (uses default define at the top) | ||
ARG PYTHON_VERSION | ||
ARG BRANCH_NAME | ||
ARG USE_ROCM_VERSION | ||
ENV PYTHONUNBUFFERED TRUE | ||
|
||
RUN --mount=type=cache,sharing=locked,target=/var/cache/apt \ | ||
apt-get update && \ | ||
apt-get upgrade -y && \ | ||
apt-get install software-properties-common -y && \ | ||
add-apt-repository -y ppa:deadsnakes/ppa && \ | ||
apt remove -y python-pip python3-pip && \ | ||
DEBIAN_FRONTEND=noninteractive apt-get install --no-install-recommends -y \ | ||
python$PYTHON_VERSION \ | ||
python3-setuptools \ | ||
|
@@ -204,30 +200,29 @@ RUN --mount=type=cache,sharing=locked,target=/var/cache/apt \ | |
&& rm -rf /var/lib/apt/lists/* \ | ||
&& cd /tmp | ||
|
||
RUN --mount=type=bind,from=compile-image,target=/mnt \ | ||
if [ "$USE_ROCM_VERSION" ]; then \ | ||
RUN --mount=type=cache,sharing=locked,id=apt-dev,target=/var/cache/apt \ | ||
if [ -n "$USE_ROCM_VERSION" ]; then \ | ||
apt-get update \ | ||
&& DEBIAN_FRONTEND=noninteractive apt-get install -y ./mnt/amdgpu-install_6.2.60202-1_all.deb \ | ||
&& wget https://repo.radeon.com/amdgpu-install/6.2.2/ubuntu/noble/amdgpu-install_6.2.60202-1_all.deb \ | ||
&& DEBIAN_FRONTEND=noninteractive apt-get install -y ./amdgpu-install_6.2.60202-1_all.deb \ | ||
&& apt-get update \ | ||
&& apt-get install --no-install-recommends -y amdgpu-dkms rocm; \ | ||
else \ | ||
echo "Skip ROCm installation"; \ | ||
fi | ||
|
||
COPY --from=compile-image /home/venv /home/venv | ||
ENV PATH="/home/venv/bin:$PATH" | ||
|
||
RUN python -m pip install --no-cache-dir -r https://raw.githubusercontent.com/pytorch/serve/$BRANCH_NAME/requirements/developer.txt | ||
|
||
COPY --from=compile-image /opt/rocm/share/amd_smi /opt/rocm/share/amd_smi | ||
ENV PATH="/home/venv/bin:$PATH" | ||
|
||
RUN \ | ||
if [ "$USE_ROCM_VERSION" ]; then \ | ||
python -m pip install /opt/rocm/share/amd_smi; \ | ||
else \ | ||
echo "Skip ROCm installation"; \ | ||
if [ -n "$USE_ROCM_VERSION" ]; then \ | ||
python$PYTHON_VERSION -m pip install -U pip setuptools \ | ||
&& python -m pip install /opt/rocm/share/amd_smi; \ | ||
fi | ||
|
||
RUN python$PYTHON_VERSION -m pip install --no-cache-dir -r https://raw.githubusercontent.com/pytorch/serve/$BRANCH_NAME/requirements/developer.txt | ||
|
||
RUN mkdir /serve | ||
ENV TS_RUN_IN_DOCKER True | ||
|
||
|
@@ -239,8 +234,8 @@ FROM ${BASE_IMAGE} as dev-image | |
# Re-state ARG PYTHON_VERSION to make it active in this build-stage (uses default define at the top) | ||
ARG PYTHON_VERSION | ||
ARG BRANCH_NAME | ||
ARG USE_ROCM_VERSION | ||
ARG BUILD_FROM_SRC | ||
ARG USE_ROCM_VERSION | ||
ARG LOCAL_CHANGES | ||
ARG BUILD_WITH_IPEX | ||
ARG IPEX_VERSION=1.11.0 | ||
|
@@ -266,22 +261,29 @@ RUN --mount=type=cache,sharing=locked,target=/var/cache/apt \ | |
# https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1009905 | ||
openjdk-17-jdk \ | ||
build-essential \ | ||
wget \ | ||
curl \ | ||
vim \ | ||
numactl \ | ||
nodejs \ | ||
npm \ | ||
zip \ | ||
unzip \ | ||
&& npm install -g [email protected] newman-reporter-htmlextra markdown-link-check \ | ||
&& rm -rf /var/lib/apt/lists/* | ||
|
||
RUN --mount=type=bind,from=compile-image,target=/mnt \ | ||
if [ "$USE_ROCM_VERSION" ]; then \ | ||
RUN --mount=type=cache,sharing=locked,id=apt-dev,target=/var/cache/apt \ | ||
if [ -n "$USE_ROCM_VERSION" ]; then \ | ||
apt-get update \ | ||
&& DEBIAN_FRONTEND=noninteractive apt-get install -y ./mnt/amdgpu-install_6.2.60202-1_all.deb \ | ||
&& wget https://repo.radeon.com/amdgpu-install/6.2.2/ubuntu/noble/amdgpu-install_6.2.60202-1_all.deb \ | ||
&& DEBIAN_FRONTEND=noninteractive apt-get install -y ./amdgpu-install_6.2.60202-1_all.deb \ | ||
&& apt-get update \ | ||
&& apt-get install --no-install-recommends -y amdgpu-dkms rocm; \ | ||
else \ | ||
echo "Skip ROCm installation"; \ | ||
fi | ||
|
||
COPY ./ /serve | ||
COPY ./ serve | ||
|
||
RUN \ | ||
if echo "$LOCAL_CHANGES" | grep -q "false"; then \ | ||
|
@@ -292,20 +294,17 @@ RUN \ | |
COPY --from=compile-image /home/venv /home/venv | ||
ENV PATH="/home/venv/bin:$PATH" | ||
|
||
WORKDIR "/serve" | ||
|
||
RUN \ | ||
if [ "$USE_ROCM_VERSION" ]; then \ | ||
python ts_scripts/install_dependencies.py --environment=dev --rocm $USE_ROCM_VERSION \ | ||
if [ -n "$USE_ROCM_VERSION" ]; then \ | ||
python$PYTHON_VERSION -m pip install -U pip setuptools \ | ||
&& python -m pip install /opt/rocm/share/amd_smi; \ | ||
# Install the binary with the latest CPU image on a ROCm base image | ||
else \ | ||
python ts_scripts/install_dependencies.py --environment=dev;\ | ||
fi; | ||
fi | ||
|
||
WORKDIR "serve" | ||
|
||
RUN python -m pip install -U pip setuptools \ | ||
&& python -m pip install --no-cache-dir -r requirements/developer.txt \ | ||
&& python ts_scripts/install_from_src.py --environment=dev \ | ||
RUN python$PYTHON_VERSION -m pip install -U pip setuptools \ | ||
&& python$PYTHON_VERSION -m pip install --no-cache-dir -r requirements/developer.txt \ | ||
&& python$PYTHON_VERSION ts_scripts/install_from_src.py --environment=dev \ | ||
&& useradd -m model-server \ | ||
&& mkdir -p /home/model-server/tmp \ | ||
&& cp docker/dockerd-entrypoint.sh /usr/local/bin/dockerd-entrypoint.sh \ | ||
|