TAO Converter with Detectnet_v2
The tao-converter
tool is provided with TAO
to facilitate the deployment of TAO trained models on TensorRT and/or Deepstream.
This section elaborates on how to generate a TensorRT engine using tao-converter
.
For deployment platforms with an x86-based CPU and discrete GPUs, the tao-converter
is distributed within the TAO docker. Therefore, we suggest using the docker to generate
the engine. However, this requires that the user adhere to the same minor version of
TensorRT as distributed with the docker. The TAO docker includes TensorRT version 8.0.
For an x86 platform with discrete GPUs, the default TAO package includes the tao-converter
built for TensorRT 8.2.5.1 with CUDA 11.4 and CUDNN 8.2. However, for any other version of CUDA and
TensorRT, please refer to the overview section for download. Once the
tao-converter
is downloaded, follow the instructions below to generate a TensorRT engine.
Unzip the zip file on the target machine.
Install the OpenSSL package using the command:
sudo apt-get install libssl-dev
Export the following environment variables:
$ export TRT_LIB_PATH=”/usr/lib/x86_64-linux-gnu”
$ export TRT_INC_PATH=”/usr/include/x86_64-linux-gnu”
Run the
tao-converter
using the sample command below and generate the engine.
Make sure to follow the output node names as mentioned in Exporting the Model
section of the respective model.
For the Jetson platform, the tao-converter
is available to download in the NVIDIA developer zone. You may choose
the version you wish to download as listed in the overview section.
Once the tao-converter
is downloaded, please follow the instructions below to generate a
TensorRT engine.
Unzip the zip file on the target machine.
Install the OpenSSL package using the command:
sudo apt-get install libssl-dev
Export the following environment variables:
$ export TRT_LIB_PATH=”/usr/lib/aarch64-linux-gnu”
$ export TRT_INC_PATH=”/usr/include/aarch64-linux-gnu”
For Jetson devices, TensorRT comes pre-installed with Jetpack. If you are using older JetPack, upgrade to JetPack-5.0DP.
Run the
tao-converter
using the sample command below and generate the engine.
Make sure to follow the output node names as mentioned in Exporting the Model
section of the respective model.
tao-converter [-h] -k <encryption_key>
-d <input_dimensions>
-o <comma separated output nodes>
[-c <path to calibration cache file>]
[-e <path to output engine>]
[-b <calibration batch size>]
[-m <maximum batch size of the TRT engine>]
[-t <engine datatype>]
[-w <maximum workspace size of the TRT Engine>]
[-i <input dimension ordering>]
[-p <optimization_profiles>]
[-s]
[-u <DLA_core>]
input_file
Required Arguments
input_file
: The path to the.etlt
model exported usingexport
.-k
: The key used to encode the.tlt
model when training.-d
: A comma-separated list of input dimensions that should match the dimensions used forexport
. Unlikeexport
, this cannot be inferred from calibration data.-o
: A comma-separated list of output blob names that should match the output configuration used forexport
. For DetectNet_v2, set this argument tooutput_cov/Sigmoid,output_bbox/BiasAdd
.
Optional Arguments
-e
: The path to save the engine to. The default path is./saved.engine
.-t
: The desired engine data type. This option generates a calibration cache if in INT8 mode. The default value isfp32
. The options arefp32
,fp16
, andint8
.-w
: The maximum workspace size for the TensorRT engine. The default value is1073741824(1<<30)
.-i
: The input dimension ordering. The default value isnchw
. The options arenchw
,nhwc
, andnc
. For detectnet_v2, you can omit this argument.-p
: The optimization profiles for.etlt
models with dynamic shape. This argument takes a comma-separated list of optimization profile shapes in the format<input_name>,<min_shape>,<opt_shape>,<max_shape>
, where each shape has the format<n>x<c>x<h>x<w>
. This can be specified multiple times if there are multiple input tensors for the model. This argument is only useful for new models introduced since TLT 3.0.-s
: A Boolean value specifying whether to apply TensorRT strict type constraints when building the TensorRT engine.-u
: Specifies the DLA core index when building the TensorRT engine on Jetson devices.
INT8 Mode Arguments
-c
: The path to the calibration cache file for INT8 mode. The default path is./cal.bin
.-b
: The batch size used during the export step for INT8 calibration cache generation (default:8
).-m
: The maximum batch size for the TensorRT engine. The default value is16
. If you encounter out-of-memory issues, decrease the batch size accordingly.
Sample Output Log
The following is a sample log for exporting a DetectNet_v2 model:
tao-converter -d 3,544,960
-k nvidia_tlt
-o output_cov/Sigmoid,output_bbox/BiasAdd
/workspace/tao-experiments/detectnet_v2/resnet18_pruned.etlt
..
[INFO] Some tactics do not have sufficient workspace memory to run. Increasing workspace size may increase performance, please check verbose output.
[INFO] Detected 1 inputs and 2 output network tensors.