Skip to content

Commit 761f6a4

Browse files
committed
optimize build
Signed-off-by: Srikanth Ramakrishna <srikanth.ramakrishna@intel.com>
1 parent 5a82012 commit 761f6a4

File tree

2 files changed

+22
-35
lines changed

2 files changed

+22
-35
lines changed

pytorch/Dockerfile

+19-31
Original file line numberDiff line numberDiff line change
@@ -242,14 +242,6 @@ ENV PATH="/home/venv/bin:$PATH"
242242

243243
WORKDIR /home/model-server
244244

245-
FROM torchserve-base AS compile-cpu
246-
247-
COPY serving/torchserve-requirements.txt .
248-
COPY requirements.txt .
249-
250-
RUN python -m pip install --no-cache-dir -r requirements.txt && \
251-
python -m pip install --no-cache-dir -r torchserve-requirements.txt
252-
253245
RUN echo -e "#!/bin/bash \n\
254246
set -e \n\
255247
if [[ \"\$1\" = "serve" ]]; then \n\
@@ -260,22 +252,20 @@ else \n\
260252
fi \n\
261253
tail -f /dev/null" >> /usr/local/bin/dockerd-entrypoint.sh
262254

255+
FROM torchserve-base AS compile-cpu
256+
257+
COPY serving/torchserve-requirements.txt .
258+
COPY requirements.txt .
259+
260+
RUN python -m pip install --no-cache-dir -r requirements.txt && \
261+
python -m pip install --no-cache-dir -r torchserve-requirements.txt
262+
263263
FROM torchserve-base AS compile-xpu
264264

265265
COPY serving/torchserve-xpu-requirements.txt .
266266

267267
RUN python -m pip install --no-cache-dir -r torchserve-xpu-requirements.txt
268268

269-
RUN echo -e "#!/bin/bash \n\
270-
set -e \n\
271-
if [[ \"\$1\" = "serve" ]]; then \n\
272-
shift 1 \n\
273-
torchserve --start --ts-config /home/model-server/config.properties --workflow-store /home/model-server/wf-store \n\
274-
else \n\
275-
eval \"\$@\" \n\
276-
fi \n\
277-
tail -f /dev/null" >> /usr/local/bin/dockerd-entrypoint.sh
278-
279269
FROM torchserve-base AS torchserve-cpu
280270

281271
USER model-server
@@ -311,6 +301,8 @@ RUN echo "deb [arch=amd64 signed-by=/usr/share/keyrings/intel-graphics.gpg] http
311301

312302
RUN apt-get update && \
313303
apt-get install -y --no-install-recommends \
304+
jq \
305+
curl \
314306
libnl-genl-3-200 \
315307
intel-gsc \
316308
libdrm2 \
@@ -319,29 +311,25 @@ RUN apt-get update && \
319311
apt-get autoremove -y && \
320312
rm -rf /var/lib/apt/lists/*
321313

322-
ARG XPU_SMI_BINARY
314+
ARG XPU_SMI_VERSION
323315

324-
RUN wget -q --no-check-certificate ${XPU_SMI_BINARY} && \
325-
ldconfig && dpkg -i --force-all *.deb && \
326-
rm -rf *.deb /etc/apt/sources.list.d/intel-gpu-jammy.list /etc/apt/sources.list.d/oneAPI.list
316+
ARG API_URL=https://api.github.com/repos/intel/xpumanager/releases/tags/V${XPU_SMI_VERSION}
327317

328-
ENV LD_LIBRARY_PATH=/opt/intel/oneapi/redist/lib:$LD_LIBRARY_PATH
318+
RUN curl -H "Accept: application/vnd.github.v3+json" -H "User-Agent: MyClient/1.0.0" "$API_URL" >> /tmp/asset_data.txt && \
319+
wget -q --no-check-certificate $(cat /tmp/asset_data.txt | jq -r '.assets[] | select(.name | test("^xpu-smi.*u22\\.04_amd64\\.deb$")) | .browser_download_url') && \
320+
ldconfig && dpkg -i --force-all *.deb && \
321+
rm -rf *.deb /etc/apt/sources.list.d/intel-gpu-jammy.list /etc/apt/sources.list.d/oneAPI.list /tmp/asset_data.txt
329322

330-
ARG model-server
331-
ARG GID
332-
ARG GNAME=render
333-
ARG VNAME=video
323+
ARG GID=109
334324

335-
RUN groupadd -g ${GID} ${GNAME}
325+
RUN groupadd -g ${GID} render
336326

337-
# RUN useradd -m -s /bin/bash model-server
338-
RUN usermod -aG ${VNAME},${GNAME} model-server
327+
RUN usermod -aG video,render model-server
339328

340329
USER model-server
341330

342331
WORKDIR /home/model-server
343332

344-
345333
RUN wget --progress=dot:giga https://raw.githubusercontent.com/pytorch/serve/master/examples/intel_extension_for_pytorch/intel_gpu_metric_collector.py && \
346334
wget --progress=dot:giga https://raw.githubusercontent.com/pytorch/serve/master/examples/intel_extension_for_pytorch/intel_gpu.py
347335

pytorch/docker-compose.yaml

+3-4
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ services:
165165
dependency.apt.openjdk-17-jdk: true
166166
dependency.idp: false
167167
dependency.python.ipex: requirements.txt
168-
dependency.python.pip: serve/torchserve-requirements.txt
168+
dependency.python.pip: serving/torchserve-requirements.txt
169169
docs: serving
170170
org.opencontainers.base.name: "intel/python:3.10-core"
171171
org.opencontainers.image.title: "Intel® Extension for PyTorch Serving Image"
@@ -185,14 +185,13 @@ services:
185185
build:
186186
args:
187187
PACKAGE_OPTION: pip
188-
GID: ${GID:-109}
189-
XPU_SMI_BINARY: ${XPU_SMI_BINARY:-https://github.com/intel/xpumanager/releases/download/V1.2.38/xpu-smi_1.2.38_20240718.060204.0db09695.u22.04_amd64.deb}
188+
XPU_SMI_VERSION: ${XPU_SMI_VERSION:-1.2.38}
190189
TORCHSERVE_BASE: ipex-xpu-base
191190
labels:
192191
dependency.apt.numactl: true
193192
dependency.apt.openjdk-17-jdk: true
194193
dependency.idp: false
195-
dependency.python.pip: serve/torchserve-xpu-requirements.txt
194+
dependency.python.pip: serving/torchserve-xpu-requirements.txt
196195
docs: serving
197196
org.opencontainers.base.name: "intel/python:3.10-core"
198197
org.opencontainers.image.title: "Intel® Extension for PyTorch XPU Serving Image"

0 commit comments

Comments
 (0)