Skip to content

Commit 056a428

Browse files
authored
iGPU build refactor (#224) (#225)
1 parent 6bc9b0b commit 056a428

File tree

2 files changed

+31
-3
lines changed

2 files changed

+31
-3
lines changed

CMakeLists.txt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,10 @@ project(tritononnxruntimebackend LANGUAGES C CXX)
7878
# version that is compatible with the specified version of ONNX
7979
# Runtime.
8080
#
81+
# - Optionally set TRITON_BUILD_TARGET_PLATFORM to either linux, windows or
82+
# igpu. If not set, the current platform will be used. If building on
83+
# Jetpack, always set to igpu to avoid misdetection.
84+
#
8185
# - If you want to disable GPU usage, set TRITON_ENABLE_GPU=OFF.
8286
# This will make builds with CUDA and TensorRT flags to fail.
8387
#
@@ -91,6 +95,7 @@ set(TRITON_BUILD_CONTAINER "" CACHE STRING "Triton container to use a base for b
9195
set(TRITON_BUILD_CONTAINER_VERSION "" CACHE STRING "Triton container version to target")
9296
set(TRITON_BUILD_ONNXRUNTIME_VERSION "" CACHE STRING "ONNXRuntime version to build")
9397
set(TRITON_BUILD_ONNXRUNTIME_OPENVINO_VERSION "" CACHE STRING "ONNXRuntime OpenVINO version to build")
98+
set(TRITON_BUILD_TARGET_PLATFORM "" CACHE STRING "Target platform for ONNXRuntime build")
9499
set(TRITON_BUILD_CUDA_VERSION "" CACHE STRING "Version of CUDA install")
95100
set(TRITON_BUILD_CUDA_HOME "" CACHE PATH "Path to CUDA install")
96101
set(TRITON_BUILD_CUDNN_HOME "" CACHE PATH "Path to CUDNN install")
@@ -313,6 +318,9 @@ endif() # TRITON_ENABLE_ONNXRUNTIME_OPENVINO
313318
#
314319
if(TRITON_ONNXRUNTIME_DOCKER_BUILD)
315320
set(_GEN_FLAGS "")
321+
if(NOT ${TRITON_BUILD_TARGET_PLATFORM} STREQUAL "")
322+
set(_GEN_FLAGS ${_GEN_FLAGS} "--target-platform=${TRITON_BUILD_TARGET_PLATFORM}")
323+
endif() # TRITON_BUILD_TARGET_PLATFORM
316324
if(NOT ${TRITON_BUILD_CUDA_VERSION} STREQUAL "")
317325
set(_GEN_FLAGS ${_GEN_FLAGS} "--cuda-version=${TRITON_BUILD_CUDA_VERSION}")
318326
endif() # TRITON_BUILD_CUDA_VERSION

tools/gen_ort_dockerfile.py

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,8 @@ def dockerfile_for_linux(output_file):
210210
ep_flags += ' --cuda_home "{}"'.format(FLAGS.cuda_home)
211211
if FLAGS.cudnn_home is not None:
212212
ep_flags += ' --cudnn_home "{}"'.format(FLAGS.cudnn_home)
213+
elif target_platform() == "igpu":
214+
ep_flags += ' --cudnn_home "/usr/lib/aarch64-linux-gnu"'
213215
if FLAGS.ort_tensorrt:
214216
ep_flags += " --use_tensorrt"
215217
if FLAGS.ort_version >= "1.12.1":
@@ -224,7 +226,11 @@ def dockerfile_for_linux(output_file):
224226
if FLAGS.ort_openvino is not None:
225227
ep_flags += " --use_openvino CPU_FP32"
226228

227-
cuda_archs = "60;61;70;75;80;86;90"
229+
if target_platform() == "igpu":
230+
ep_flags += " --skip_tests --cmake_extra_defines 'onnxruntime_BUILD_UNIT_TESTS=OFF'"
231+
cuda_archs = "53;62;72;87"
232+
else:
233+
cuda_archs = "60;61;70;75;80;86;90"
228234

229235
df += """
230236
WORKDIR /workspace/onnxruntime
@@ -264,14 +270,21 @@ def dockerfile_for_linux(output_file):
264270
/opt/onnxruntime/lib && \
265271
cp /workspace/build/${ONNXRUNTIME_BUILD_CONFIG}/libonnxruntime.so \
266272
/opt/onnxruntime/lib
267-
273+
"""
274+
if target_platform() == "igpu":
275+
df += """
276+
RUN mkdir -p /opt/onnxruntime/bin
277+
"""
278+
else:
279+
df += """
268280
RUN mkdir -p /opt/onnxruntime/bin && \
269281
cp /workspace/build/${ONNXRUNTIME_BUILD_CONFIG}/onnxruntime_perf_test \
270282
/opt/onnxruntime/bin && \
271283
cp /workspace/build/${ONNXRUNTIME_BUILD_CONFIG}/onnx_test_runner \
272284
/opt/onnxruntime/bin && \
273285
(cd /opt/onnxruntime/bin && chmod a+x *)
274286
"""
287+
275288
if FLAGS.enable_gpu:
276289
df += """
277290
RUN cp /workspace/build/${ONNXRUNTIME_BUILD_CONFIG}/libonnxruntime_providers_cuda.so \
@@ -334,6 +347,13 @@ def dockerfile_for_linux(output_file):
334347
done
335348
336349
# For testing copy ONNX custom op library and model
350+
"""
351+
if target_platform() == "igpu":
352+
df += """
353+
RUN mkdir -p /opt/onnxruntime/test
354+
"""
355+
else:
356+
df += """
337357
RUN mkdir -p /opt/onnxruntime/test && \
338358
cp /workspace/build/${ONNXRUNTIME_BUILD_CONFIG}/libcustom_op_library.so \
339359
/opt/onnxruntime/test && \
@@ -533,7 +553,7 @@ def preprocess_gpu_flags():
533553
"--target-platform",
534554
required=False,
535555
default=None,
536-
help='Target for build, can be "ubuntu", "windows" or "jetpack". If not specified, build targets the current platform.',
556+
help='Target for build, can be "linux", "windows" or "igpu". If not specified, build targets the current platform.',
537557
)
538558

539559
parser.add_argument(

0 commit comments

Comments
 (0)