This sample demonstrates how to use TensorRT for RTX APIs to fine-tune engine compilation and inference. First please refer to the Hello World sample that goes over the basic concepts. In addition, this sample covers
- Creating a TensorRT-RTX builder and network definition with dynamic shapes and setting AoT compilation targets using the
setComputeCapabilityand associated API. - Efficiently checking if an engine file is expected to work for the current platform/environment using the Engine Compatibility API.
- Configuring and serializing a runtime cache via
setRuntimeCacheand associated API to store JIT compiled kernels. - Setting, querying and running inference with dynamic shape information via various dynamic shape APIs.
- Building weightless engines, and subsequently refitting weights on the deployed machines using the refit APIs.
- Running inference for multiple input shapes with the compiled engine.
- CMake 3.10 or later
- Python 3.9 or later
- CUDA Toolkit
- An installation of TensorRT for RTX
On Windows, add the TensorRT for RTX lib directory to your PATH environment variable:
$Env:PATH += ";$Env:PATH_TO_TRT_RTX\lib"On Linux, add the TensorRT for RTX lib directory to your LD_LIBRARY_PATH environment variable:
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:${PATH_TO_TRT_RTX}/lib-
Run CMake from the current or the
cppdirectory, pointing it to your TensorRT for RTX installation, to create artifacts in thebuilddirectorycmake -B build -S . -DTRTRTX_INSTALL_DIR=/path/to/tensorrt-rtx -
Build the sample:
cmake --build build
-
Install TensorRT-RTX:
python -m pip install tensorrt-rtx
-
Install
numpyandcuda-pythonfrom thepython/requirements.txtfile:python -m pip install -r python/requirements.txt
After building, you can run the sample with:
./apiUsagefrom the build directory.
For the Python sample, run:
python api_usage.pyThe sample will:
- Create and compile a simple neural network with dynamic shapes.
- Build a weightless engine on the current device and then refuel its weights.
- Run inference with different batch sizes and input values.
- Display the results.
The sample demonstrates several key concepts related to TensorRT for RTX APIs:
- Network creation and configuration for dynamically-shaped input tensors.
- Selecting deployment targets at AOT.
- Configuring a weightless engine and refueling weights during deployment.
- Using runtime cache to store JIT-compiled kernels.
- Inference execution with changing dynamic shapes.
For detailed comments explaining each step, please refer to the apiUsage.cpp and api_usage.py source files.