Skip to content

Commit 1cab7c8

Browse files
committed
Update Dockerfile generation
1 parent 4b6fd4d commit 1cab7c8

File tree

1 file changed

+16
-40
lines changed

1 file changed

+16
-40
lines changed

tools/gen_ort_dockerfile.py

Lines changed: 16 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -177,19 +177,7 @@ def dockerfile_for_linux(output_file):
177177
gnupg \
178178
gnupg1
179179
180-
RUN pip3 install patchelf==0.17.2
181-
182-
# Install dependencies from
183-
# onnxruntime/dockerfiles/scripts/install_common_deps.sh.
184-
RUN apt update -q=2 \\
185-
&& apt install -y gpg wget \\
186-
&& wget -O - https://apt.kitware.com/keys/kitware-archive-latest.asc 2>/dev/null | gpg --dearmor - | tee /usr/share/keyrings/kitware-archive-keyring.gpg >/dev/null \\
187-
&& . /etc/os-release \\
188-
&& echo "deb [signed-by=/usr/share/keyrings/kitware-archive-keyring.gpg] https://apt.kitware.com/ubuntu/ $UBUNTU_CODENAME main" | tee /etc/apt/sources.list.d/kitware.list >/dev/null \\
189-
&& apt-get update -q=2 \\
190-
&& apt-get install -y --no-install-recommends cmake=3.28.3* cmake-data=3.28.3* \\
191-
&& cmake --version
192-
180+
RUN pip3 install patchelf==0.17.2 cmake==4.0.3
193181
"""
194182

195183
if FLAGS.ort_openvino is not None:
@@ -279,11 +267,7 @@ def dockerfile_for_linux(output_file):
279267
ARG ONNXRUNTIME_REPO
280268
ARG ONNXRUNTIME_BUILD_CONFIG
281269
282-
# Cherry-pick commit: https://github.com/microsoft/onnxruntime/commit/9dad9af9f9b48c05814d0c2d067d0565e8da6ce8
283-
RUN git clone -b rel-${ONNXRUNTIME_VERSION} --recursive ${ONNXRUNTIME_REPO} onnxruntime \\
284-
&& cd onnxruntime \\
285-
&& git cherry-pick -n 9dad9af9f9b48c05814d0c2d067d0565e8da6ce8 \\
286-
&& sed -i 's/5ea4d05e62d7f954a46b3213f9b2535bdd866803/51982be81bbe52572b54180454df11a3ece9a934/g' cmake/deps.txt
270+
RUN git clone -b main --recursive ${ONNXRUNTIME_REPO} onnxruntime
287271
"""
288272

289273
if FLAGS.onnx_tensorrt_tag != "":
@@ -367,38 +351,30 @@ def dockerfile_for_linux(output_file):
367351
# Copy all artifacts needed by the backend to /opt/onnxruntime
368352
#
369353
WORKDIR /opt/onnxruntime
370-
371-
RUN mkdir -p /opt/onnxruntime && \
372-
cp /workspace/onnxruntime/LICENSE /opt/onnxruntime && \
373-
cat /workspace/onnxruntime/cmake/external/onnx/VERSION_NUMBER > /opt/onnxruntime/ort_onnx_version.txt
354+
RUN cp /workspace/onnxruntime/LICENSE . \\
355+
&& cat /workspace/onnxruntime/cmake/external/onnx/VERSION_NUMBER > ort_onnx_version.txt
374356
375357
# ONNX Runtime headers, libraries and binaries
376-
RUN mkdir -p /opt/onnxruntime/include && \
377-
cp /workspace/onnxruntime/include/onnxruntime/core/session/onnxruntime_c_api.h \
378-
/opt/onnxruntime/include && \
379-
cp /workspace/onnxruntime/include/onnxruntime/core/session/onnxruntime_session_options_config_keys.h \
380-
/opt/onnxruntime/include && \
381-
cp /workspace/onnxruntime/include/onnxruntime/core/providers/cpu/cpu_provider_factory.h \
382-
/opt/onnxruntime/include
358+
WORKDIR /opt/onnxruntime/include
359+
RUN cp /workspace/onnxruntime/include/onnxruntime/core/session/onnxruntime_c_api.h . \\
360+
&& cp /workspace/onnxruntime/include/onnxruntime/core/session/onnxruntime_session_options_config_keys.h . \\
361+
&& cp /workspace/onnxruntime/include/onnxruntime/core/providers/cpu/cpu_provider_factory.h . \\
362+
&& cp /workspace/onnxruntime/include/onnxruntime/core/session/onnxruntime_ep_c_api.h .
383363
384-
RUN mkdir -p /opt/onnxruntime/lib && \
385-
cp /workspace/build/${ONNXRUNTIME_BUILD_CONFIG}/libonnxruntime_providers_shared.so \
386-
/opt/onnxruntime/lib && \
387-
cp /workspace/build/${ONNXRUNTIME_BUILD_CONFIG}/libonnxruntime.so \
388-
/opt/onnxruntime/lib
364+
WORKDIR /opt/onnxruntime/lib
365+
RUN cp /workspace/build/${ONNXRUNTIME_BUILD_CONFIG}/libonnxruntime_providers_shared.so . \\
366+
&& cp /workspace/build/${ONNXRUNTIME_BUILD_CONFIG}/libonnxruntime.so .
389367
"""
390368
if target_platform() == "igpu":
391369
df += """
392370
RUN mkdir -p /opt/onnxruntime/bin
393371
"""
394372
else:
395373
df += """
396-
RUN mkdir -p /opt/onnxruntime/bin && \
397-
cp /workspace/build/${ONNXRUNTIME_BUILD_CONFIG}/onnxruntime_perf_test \
398-
/opt/onnxruntime/bin && \
399-
cp /workspace/build/${ONNXRUNTIME_BUILD_CONFIG}/onnx_test_runner \
400-
/opt/onnxruntime/bin && \
401-
(cd /opt/onnxruntime/bin && chmod a+x *)
374+
WORKDIR /opt/onnxruntime/bin
375+
RUN cp /workspace/build/${ONNXRUNTIME_BUILD_CONFIG}/onnxruntime_perf_test . \\
376+
&& cp /workspace/build/${ONNXRUNTIME_BUILD_CONFIG}/onnx_test_runner . \\
377+
&& chmod a+x *
402378
"""
403379

404380
if FLAGS.enable_gpu:

0 commit comments

Comments
 (0)