Skip to content

Commit 816f148

Browse files
committed
Update 'gen_ort_dockerfile.py' fil to meet changes in ONNX Runtime 1.20.x
1 parent d646603 commit 816f148

File tree

1 file changed

+16
-27
lines changed

1 file changed

+16
-27
lines changed

tools/gen_ort_dockerfile.py

Lines changed: 16 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -157,16 +157,8 @@ def dockerfile_for_linux(output_file):
157157
&& apt-get install -y --no-install-recommends cmake=3.28.3* cmake-data=3.28.3* \\
158158
&& cmake --version
159159
160-
"""
161-
if FLAGS.enable_gpu:
162-
df += """
163-
# Allow configure to pick up cuDNN where it expects it.
164-
# (Note: $CUDNN_VERSION is defined by base image)
165-
RUN _CUDNN_VERSION=$(echo $CUDNN_VERSION | cut -d. -f1-2) && \
166-
mkdir -p /usr/local/cudnn-$_CUDNN_VERSION/cuda/include && \
167-
ln -s /usr/include/cudnn.h /usr/local/cudnn-$_CUDNN_VERSION/cuda/include/cudnn.h && \
168-
mkdir -p /usr/local/cudnn-$_CUDNN_VERSION/cuda/lib64 && \
169-
ln -s /etc/alternatives/libcudnn_so /usr/local/cudnn-$_CUDNN_VERSION/cuda/lib64/libcudnn.so
160+
RUN python3 -m pip install psutil
161+
170162
"""
171163

172164
if FLAGS.ort_openvino is not None:
@@ -287,7 +279,7 @@ def dockerfile_for_linux(output_file):
287279

288280
df += """
289281
WORKDIR /workspace/onnxruntime
290-
ARG COMMON_BUILD_ARGS="--config ${{ONNXRUNTIME_BUILD_CONFIG}} --skip_submodule_sync --parallel --build_shared_lib \
282+
ARG COMMON_BUILD_ARGS="--config ${{ONNXRUNTIME_BUILD_CONFIG}} --skip_submodule_sync --parallel 2 --build_shared_lib \
291283
--compile_no_warning_as_error --build_dir /workspace/build --cmake_extra_defines CMAKE_CUDA_ARCHITECTURES='{}' "
292284
""".format(
293285
cuda_archs
@@ -395,7 +387,7 @@ def dockerfile_for_linux(output_file):
395387
"""
396388
df += """
397389
RUN cd /opt/onnxruntime/lib && \
398-
for i in `find . -mindepth 1 -maxdepth 1 -type f -name '*\.so*'`; do \
390+
for i in `find . -mindepth 1 -maxdepth 1 -type f -name '*\\.so*'`; do \
399391
patchelf --set-rpath '$ORIGIN' $i; \
400392
done
401393
@@ -476,7 +468,7 @@ def dockerfile_for_windows(output_file):
476468

477469
df += """
478470
WORKDIR /workspace/onnxruntime
479-
ARG VS_DEVCMD_BAT="\BuildTools\VC\Auxiliary\Build\vcvars64.bat"
471+
ARG VS_DEVCMD_BAT="\\BuildTools\\VC\\Auxiliary\\Build\\vcvars64.bat"
480472
RUN powershell Set-Content 'build.bat' -value 'call %VS_DEVCMD_BAT%',(Get-Content 'build.bat')
481473
RUN build.bat --cmake_generator "Visual Studio 17 2022" --config Release --cmake_extra_defines "CMAKE_CUDA_ARCHITECTURES=75;80;86;90" --skip_submodule_sync --parallel --build_shared_lib --compile_no_warning_as_error --skip_tests --update --build --build_dir /workspace/build {}
482474
""".format(
@@ -559,12 +551,8 @@ def preprocess_gpu_flags():
559551
FLAGS.tensorrt_home = "/tensorrt"
560552
else:
561553
if "CUDNN_VERSION" in os.environ:
562-
version = None
563-
m = re.match(r"([0-9]\.[0-9])\.[0-9]\.[0-9]", os.environ["CUDNN_VERSION"])
564-
if m:
565-
version = m.group(1)
566554
if FLAGS.cudnn_home is None:
567-
FLAGS.cudnn_home = "/usr/local/cudnn-{}/cuda".format(version)
555+
FLAGS.cudnn_home = "/usr"
568556

569557
if FLAGS.cuda_home is None:
570558
FLAGS.cuda_home = "/usr/local/cuda"
@@ -573,13 +561,13 @@ def preprocess_gpu_flags():
573561
print("error: linux build requires --cudnn-home and --cuda-home")
574562

575563
if FLAGS.tensorrt_home is None:
576-
if target_platform() == "rhel":
577-
if platform.machine().lower() == "aarch64":
578-
FLAGS.tensorrt_home = "/usr/local/cuda/targets/sbsa-linux/"
579-
else:
580-
FLAGS.tensorrt_home = "/usr/local/cuda/targets/x86_64-linux/"
581-
else:
582-
FLAGS.tensorrt_home = "/usr/src/tensorrt"
564+
if target_platform() == "rhel":
565+
if platform.machine().lower() == "aarch64":
566+
FLAGS.tensorrt_home = "/usr/local/cuda/targets/sbsa-linux/"
567+
else:
568+
FLAGS.tensorrt_home = "/usr/local/cuda/targets/x86_64-linux/"
569+
else:
570+
FLAGS.tensorrt_home = "/usr/src/tensorrt"
583571

584572

585573
if __name__ == "__main__":
@@ -609,8 +597,9 @@ def preprocess_gpu_flags():
609597
"--target-platform",
610598
required=False,
611599
default=None,
612-
help='Target for build, can be "linux", "windows", "rhel", or "igpu". If not specified, build targets the current platform.',
600+
help='Target for build, can be "linux", "windows" or "igpu". If not specified, build targets the current platform.',
613601
)
602+
614603
parser.add_argument(
615604
"--cuda-version", type=str, required=False, help="Version for CUDA."
616605
)
@@ -667,4 +656,4 @@ def preprocess_gpu_flags():
667656
FLAGS.ort_openvino = None
668657
dockerfile_for_windows(FLAGS.output)
669658
else:
670-
dockerfile_for_linux(FLAGS.output)
659+
dockerfile_for_linux(FLAGS.output)

0 commit comments

Comments
 (0)