TensorRtInferenceOp
🚧 Documentation is under development
The Holoscan SDK guide is currently under active development. Some sections may be incomplete or change without notice.
Questions? Contact RidgeRun or email to support@ridgerun.com.
-
Overview
-
Build, Run, and Validate
-
Core Concepts
-
Operators and Graphs
-
Tensor Data and Memory
-
Interprocess Communication
-
-
Application and Operator Development
- Building an HSDK Application
- Writing a Minimal Operator
- Typed Parameters and Configuration
- Reading, Writing, and Forwarding Data
- Writing Tensor Operators
- Complete Operator Patterns
- Authoring Runtime Behavior
- Runtime Parameter Updates
- Lifecycle Callbacks and Restart Control
- Performance and Debugging
- SDK Source Map
-
Operator Reference
-
Core Operators
-
Holoscan Camera
-
Holoscan RidgeRun
- Overview
- Build and Installation
- ArgusCameraOp
- V4L2SourceOp
- V4L2UserPtrSourceOp
- BgraToPlanarTensorOp
- RawBayerToBgraOp
- RawBayerToYoloTensorOp
- YuyvToBgraOp
- TensorRtInferenceOp
- DrmDisplayOp
- DrmBgraDisplayOp
- X11DisplayOp
- CudaCompositorOp
- DepthColorizerOp
- FakesinkOp
- FrameSkipperOp
- InterprocessSrcOp
- TestPatternOp
-
-
Migration from Holoscan 4.x
-
Examples
-
Core
-
Holoscan Camera
-
Holoscan RidgeRun
-
-
Benchmark and Use Cases
-
Holoscan vs GStreamer
- Overview
-
Capture and Display
-
Capture and Inference
- Compare the workloads
- Implemented Applications
- Framework Selection
- Interprocess
-
TensorRtInferenceOp
TensorRtInferenceOp executes a static single-input/single-output TensorRT network on CUDA tensors. It accepts either a serialized TensorRT engine or an ONNX model that is built for the selected GPU during startup.
Input arguments
| Argument | Default and meaning |
|---|---|
model_path
|
Required path to an .onnx model or serialized TensorRT engine.
|
engine_cache_path
|
Empty by default. For ONNX input, an optional serialized-engine cache path. |
cuda_device
|
CUDA device used for engine building and execution; defaults to 0.
|
max_output_bytes
|
8 MiB by default; upper bound declared for the runtime output Tensor.
|
When an ONNX model is used, the operator validates the model identity before reusing a cache. A stale cache is rebuilt instead of being silently paired with a different model file.
Ports and data contract
| Port | Memory | Queue | Trigger | Contract |
|---|---|---|---|---|
input
|
CUDA device | SDK default | OnEach
|
F32 Tensor. The loaded network must expose exactly one linear, non-vectorized device F32 input. |
output
|
CUDA device, runtime pool | N/A | Same activation | F32 Tensor with shape discovered from the network and bounded by max_output_bytes.
|
The input shape must match the loaded engine. The normal device path binds TensorRT directly to CUDA Tensor memory.
V4L2UserPtrSourceOp -> RawBayerToYoloTensorOp -> TensorRtInferenceOp -> FakesinkOp
Build
Follow Holoscan RidgeRun Build and Installation for the module build and installation. The operator-specific include, target, and runtime requirements are listed below.
Include tensorrt_inference/tensorrt_inference.hpp and link holoscan::tensorrt_inference. The operator requires CUDA, TensorRT and the ONNX parser.
Example
The repository's headless YOLO application constructs the operator after the fused RG10 preprocessing stage:
auto inference = graph.op<TensorRtInferenceOp>(
"inference", model_path, engine_cache_path, 0, 8U * 1024U * 1024U);
graph.add_flow(preprocess->output, inference->input);
compile_options.deployment.bind_tensor_output_device(
holoscan::TensorOutputDevicePlacement{
.operator_path = "inference",
.output_port = "output",
.device = holoscan::DeviceId{0}});
The model file may be a serialized TensorRT engine or an ONNX file. For ONNX, an optional cache is protected by a lock and accompanied by a model-identity record. A cache whose identity does not match the current model is ignored and rebuilt. The operator reports the discovered input and output names and byte sizes at startup.
Model requirements
The loaded network must have exactly one input and one output, both linear, non-vectorized, device-resident float32 tensors. Dynamic or zero dimensions are rejected by the current implementation. The output rank and byte span must fit the declared max_output_bytes bound. During compute, the input shape and byte size must match the engine exactly; the output Tensor is allocated from the runtime pool and bound directly to TensorRT with setTensorAddress.
The normal path does not stage tensors through host memory. A missing CUDA stream, invalid Tensor placement, failed engine/context creation or failed enqueueV3 returns an operator error. stop() destroys the execution context, engine and runtime resources after the graph has stopped.