Cross Compiling Samples#
The following sections show how to cross-compile TensorRT samples for AArch64 QNX and Linux platforms under x86_64 Linux. This is an advanced topic for users who need to build samples for embedded platforms.
Prerequisites
Complete the following steps before cross-compiling for any target platform.
Install the CUDA cross-platform toolkit for your target and set the environment variables:
$ export CUDA_INSTALL_DIR=/usr/local/cuda $ export TRT_LIBPATH=/path/to/tensorrt/lib
Note
If you install TensorRT from the network repository, install the
cuda-toolkit-X-Yandcuda-cross-<arch>-X-Ypackages first to ensure all CUDA dependencies are available.Install the TensorRT cross-compilation Debian packages for your target:
QNX AArch64:
tensorrt-dev-cross-qnxLinux AArch64:
tensorrt-dev-cross-aarch64Linux SBSA:
tensorrt-dev-cross-sbsa
Note
You can skip this step if you use the tar file release, which already includes the cross-compile libraries.
(Linux AArch64 and SBSA only) Install the AArch64 cross-compiler:
$ sudo apt-get install g++-aarch64-linux-gnu
Building Samples for QNX AArch64
Download the QNX toolchain, set the environment variable, and build:
$ export QNX_BASE=/path/to/your/qnx/toolchain
$ cd <cloned_tensorrt_dir>
$ mkdir build && cd build
$ cmake .. \
-DTRT_LIB_DIR=$TRT_LIBPATH \
-DCMAKE_TOOLCHAIN_FILE=../cmake/toolchains/cmake_qnx.toolchain \
-DBUILD_SAMPLES=ON
$ make -j$(nproc)
Building Samples for Linux AArch64
Build for Linux AArch64 platforms (for example, Jetson devices):
$ cd <cloned_tensorrt_dir>
$ mkdir -p build && cd build
$ cmake .. \
-DTRT_LIB_DIR=$TRT_LIBPATH \
-DCMAKE_TOOLCHAIN_FILE=../cmake/toolchains/cmake_aarch64_cross.toolchain \
-DBUILD_SAMPLES=ON
$ make -j$(nproc)
Building Samples for Linux SBSA
Build for Linux SBSA (Server Base System Architecture) platforms:
$ cd <cloned_tensorrt_dir>
$ mkdir -p build && cd build
$ cmake .. \
-DTRT_LIB_DIR=$TRT_LIBPATH \
-DCMAKE_TOOLCHAIN_FILE=../cmake/toolchains/cmake_sbsa_cross.toolchain \
-DBUILD_SAMPLES=ON
$ make -j$(nproc)