Building and Running C++ Samples#
You can find the C++ samples in GitHub: TensorRT C++ Samples. For a complete list of C++ samples, refer to the Sample Explorer, or start with the Quick Start section for beginner-friendly options.
Every C++ sample includes a README.md file that provides detailed information about how the sample works, sample code, and step-by-step instructions on how to run and verify its output.
Building C++ Samples for All Platforms
To build all the samples, use the following commands:
$ cd <cloned_tensorrt_dir>
$ mkdir build && cd build
$ cmake .. \
-DTRT_LIB_DIR=$TRT_LIBPATH \
-DTRT_OUT_DIR=`pwd`/out \
-DBUILD_SAMPLES=ON \
-DBUILD_PARSERS=OFF \
-DBUILD_PLUGINS=OFF
$ cmake --build . --parallel 4
Sample binaries are available under <cloned_tensorrt_dir>/build/out.
Samples Installation
Samples are no longer included in release packages. To build TensorRT samples, fetch them from GitHub and build as shown below.
git clone -b release/11.0 https://github.com/NVIDIA/TensorRT.git
cd TensorRT
mkdir build && cd build
cmake .. \
-DTRT_LIB_DIR=$TRT_LIBPATH \
-DTRT_OUT_DIR=`pwd`/out \
-DBUILD_SAMPLES=ON \
-DBUILD_PARSERS=OFF \
-DBUILD_PLUGINS=OFF
cmake --build . --parallel 4
Running C++ Samples on Linux
To run a single sample on Linux:
$ cd <cloned_tensorrt_dir>/build/out
$ ./<sample_bin>
Running C++ Samples on Windows
To run a single sample on Windows:
> cd <cloned_tensorrt_dir>\build\out
> .\<sample_bin>