@@ -34,6 +34,7 @@ ARG BASE_IMAGE_TAG
34
34
ARG PACKAGE_OPTION=pip
35
35
ARG PYTHON_VERSION
36
36
ARG PYTHON_BASE=${REGISTRY}/${REPO}:b-${GITHUB_RUN_NUMBER}-${BASE_IMAGE_NAME}-${BASE_IMAGE_TAG}-${PACKAGE_OPTION}-py${PYTHON_VERSION}-base
37
+ ARG TORCHSERVE_BASE=${PYTHON_BASE}
37
38
FROM ${PYTHON_BASE} AS ipex-base-pip
38
39
39
40
WORKDIR /
@@ -181,13 +182,17 @@ RUN apt-get update && \
181
182
intel-oneapi-runtime-mkl=${MKL_VER} \
182
183
intel-oneapi-runtime-ccl=${CCL_VER};
183
184
185
+ RUN rm -rf /etc/apt/sources.list.d/intel-gpu-jammy.list /etc/apt/sources.list.d/oneAPI.list
186
+
187
+ ENV LD_LIBRARY_PATH=/opt/intel/oneapi/redist/lib:$LD_LIBRARY_PATH
188
+
189
+ FROM ipex-xpu-base AS ipex-xpu-base-wheels
190
+
184
191
WORKDIR /
185
192
COPY xpu-requirements.txt .
186
193
187
194
RUN python -m pip install --no-cache-dir -r xpu-requirements.txt && \
188
- rm -rf xpu-requirements.txt /etc/apt/sources.list.d/intel-gpu-jammy.list /etc/apt/sources.list.d/oneAPI.list
189
-
190
- ENV LD_LIBRARY_PATH=/opt/intel/oneapi/redist/lib:$LD_LIBRARY_PATH
195
+ rm -rf xpu-requirements.txt
191
196
192
197
FROM ipex-xpu-base AS ipex-xpu-jupyter
193
198
@@ -205,7 +210,8 @@ EXPOSE 8888
205
210
206
211
CMD ["bash" , "-c" , "source /etc/bash.bashrc && jupyter notebook --notebook-dir=/jupyter --port 8888 --ip 0.0.0.0 --no-browser --allow-root --ServerApp.token= --ServerApp.password= --ServerApp.allow_origin=* --ServerApp.base_url=$NB_PREFIX" ]
207
212
208
- FROM ${PYTHON_BASE} as torchserve-base
213
+
214
+ FROM ${TORCHSERVE_BASE} as torchserve-base
209
215
210
216
ENV PYTHONUNBUFFERED=TRUE
211
217
@@ -221,8 +227,6 @@ RUN useradd -m -s /bin/bash model-server && \
221
227
mkdir -p /home/model-server/model-store && \
222
228
chown -R model-server /home/model-server/
223
229
224
- FROM torchserve-base AS compile
225
-
226
230
RUN apt-get update -y && apt-get install -y --no-install-recommends --fix-missing \
227
231
g++ \
228
232
git \
@@ -237,11 +241,6 @@ RUN python3 -m venv /home/venv
237
241
ENV PATH="/home/venv/bin:$PATH"
238
242
239
243
WORKDIR /home/model-server
240
- COPY torchserve-requirements.txt .
241
- COPY requirements.txt .
242
-
243
- RUN python -m pip install --no-cache-dir -r requirements.txt && \
244
- python -m pip install --no-cache-dir -r torchserve-requirements.txt
245
244
246
245
RUN echo -e "#!/bin/bash \n \
247
246
set -e \n \
@@ -253,13 +252,29 @@ else \n\
253
252
fi \n \
254
253
tail -f /dev/null" >> /usr/local/bin/dockerd-entrypoint.sh
255
254
256
- FROM torchserve-base AS torchserve
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
+ rm -rf requirements.txt torchserve-requirements.txt
263
+
264
+ FROM torchserve-base AS compile-xpu
265
+
266
+ COPY serving/torchserve-xpu-requirements.txt .
267
+
268
+ RUN python -m pip install --no-cache-dir -r torchserve-xpu-requirements.txt && \
269
+ rm -rf torchserve-xpu-requirements.txt
270
+
271
+ FROM torchserve-base AS torchserve-cpu
257
272
258
273
USER model-server
259
274
WORKDIR /home/model-server
260
275
261
- COPY --chown=model-server --from=compile /home/venv /home/venv
262
- COPY --chown=model-server --chmod=755 --from=compile /usr/local/bin/dockerd-entrypoint.sh /usr/local/bin/dockerd-entrypoint.sh
276
+ COPY --chown=model-server --from=compile-cpu /home/venv /home/venv
277
+ COPY --chown=model-server --chmod=755 --from=compile-cpu /usr/local/bin/dockerd-entrypoint.sh /usr/local/bin/dockerd-entrypoint.sh
263
278
COPY --chown=model-server serving/config.properties /home/model-server/config.properties
264
279
265
280
ENV PATH="/home/venv/bin:$PATH"
@@ -270,3 +285,64 @@ EXPOSE 8080 8081 8082 7070 7071
270
285
271
286
ENTRYPOINT ["/usr/local/bin/dockerd-entrypoint.sh" ]
272
287
CMD ["serve" ]
288
+
289
+ FROM torchserve-base AS torchserve-xpu
290
+
291
+ RUN apt-get update && \
292
+ apt-get install -y --no-install-recommends --fix-missing \
293
+ gnupg2 \
294
+ gpg-agent \
295
+ rsync && \
296
+ apt-get clean && \
297
+ rm -rf /var/lib/apt/lists/*
298
+
299
+ RUN wget -qO - https://repositories.intel.com/gpu/intel-graphics.key | \
300
+ gpg --dearmor --yes --output /usr/share/keyrings/intel-graphics.gpg
301
+ RUN echo "deb [arch=amd64 signed-by=/usr/share/keyrings/intel-graphics.gpg] https://repositories.intel.com/gpu/ubuntu jammy unified" | \
302
+ tee /etc/apt/sources.list.d/intel-gpu-jammy.list
303
+
304
+ RUN apt-get update && \
305
+ apt-get install -y --no-install-recommends \
306
+ jq \
307
+ curl \
308
+ libnl-genl-3-200 \
309
+ intel-gsc \
310
+ libdrm2 \
311
+ intel-metrics-discovery \
312
+ intel-metrics-library && \
313
+ apt-get autoremove -y && \
314
+ rm -rf /var/lib/apt/lists/*
315
+
316
+ ARG XPU_SMI_VERSION
317
+
318
+ ARG API_URL=https://api.github.com/repos/intel/xpumanager/releases/tags/V${XPU_SMI_VERSION}
319
+
320
+ RUN wget -q --header="Accept: application/vnd.github.v3+json" --header="User-Agent: MyClient/1.0.0" -O - "$API_URL" | tee /tmp/asset_data.txt && \
321
+ wget -q --no-check-certificate "$(jq -r '.assets[] | select(.name | test(" ^xpu-smi.*u22\\ .04_amd64\\ .deb$")) | .browser_download_url' < /tmp/asset_data.txt)" && \
322
+ ldconfig && dpkg -i --force-all -- *.deb && \
323
+ rm -rf -- *.deb /etc/apt/sources.list.d/intel-gpu-jammy.list /etc/apt/sources.list.d/oneAPI.list /tmp/asset_data.txt
324
+
325
+ ARG GID=109
326
+
327
+ RUN groupadd -g ${GID} render &&\
328
+ usermod -aG video,render model-server
329
+
330
+ USER model-server
331
+
332
+ WORKDIR /home/model-server
333
+
334
+ RUN wget --progress=dot:giga https://raw.githubusercontent.com/pytorch/serve/master/examples/intel_extension_for_pytorch/intel_gpu_metric_collector.py && \
335
+ wget --progress=dot:giga https://raw.githubusercontent.com/pytorch/serve/master/examples/intel_extension_for_pytorch/intel_gpu.py
336
+
337
+ COPY --chown=model-server --from=compile-xpu /home/venv /home/venv
338
+ COPY --chown=model-server --chmod=755 --from=compile-xpu /usr/local/bin/dockerd-entrypoint.sh /usr/local/bin/dockerd-entrypoint.sh
339
+ COPY --chown=model-server serving/config-xpu.properties /home/model-server/config.properties
340
+
341
+ ENV PATH="/home/venv/bin:$PATH"
342
+ ENV TEMP=/home/model-server/tmp
343
+
344
+ # 8080/8081/8082 REST and 7070/7071 gRPC
345
+ EXPOSE 8080 8081 8082 7070 7071
346
+
347
+ ENTRYPOINT ["/usr/local/bin/dockerd-entrypoint.sh" ]
348
+ CMD ["serve" ]
0 commit comments