Deprecation Warnings When Including NvOnnxParser.h

I’m trying to write a TensorRT application reads in a pre-trained ONNX net and uses that for inference.

So, I downloaded all the normal TensorRT libs and headers via the .deb files. These don’t seem to include the ONNX and Caffe parsers.

I git cloned the TensorRT repo and I can build that along with the samples. This include the NvOnnxParser header and library. I can build and link just fine but when I include this header, I get a lot of deprecation warnings.

[build] /home/christian/TensorRT/include/NvInfer.h: In constructor ‘nvinfer1::DimsHW::DimsHW()’:
[build] /home/christian/TensorRT/include/NvInfer.h:91:3: warning: ‘nvinfer1::Dims::type’ is deprecated [-Wdeprecated-declarations]
[build]          type[0] = type[1] = DimensionType::kSPATIAL;
[build]    ^   
[build] /home/christian/TensorRT/include/NvInferRuntimeCommon.h:179:43: note: declared here
[build]      TRT_DEPRECATED DimensionType type[MAX_DIMS];  //!< The type of each dimension.
[build]                                            ^
[build] /home/christian/TensorRT/include/NvInfer.h:91:3: warning: ‘nvinfer1::Dims::type’ is deprecated [-Wdeprecated-declarations]
[build]          type[0] = type[1] = DimensionType::kSPATIAL;
[build]    ^

I’ve noticed this is because everything is written using

#include "NvInfer.h"

So what happens is, the local headers are included before the systems ones are.

I guess my question is, did I install TensorRT wrong? I can remove the .deb installs and start over again, that’s not a big deal.

But I’m just curious, is this normal/expected behavior? I can run the Onnx MNIST sample just fine (once I finally figured out where that data directory was).


It seems APIs have been annotated as deprecated, hence the compiler displaying the warning that code is using deprecated functionality.
You should update your code in order to remove such warning.

Also, can you provide details on the platforms you are using:
o Linux distro and version
o GPU type
o Nvidia driver version
o CUDA version
o CUDNN version
o Python version [if using python]
o Tensorflow and PyTorch version
o TensorRT version


I’m using Ubuntu 18.04.

Linux christian-XPS-15-7590 5.3.0-28-generic #30~18.04.1-Ubuntu SMP Fri Jan 17 06:14:09 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux

I have a GeForce GTX 1650. This is in a Dell XPS 15.

Driver version: 440.33.01


Version 7, aka

Python 3.6.9

Torch version 1.3

The latest, version 7.

I did a system install of cuDNN and TensorRT but they should be the latest.

I’m guessing maybe the git repo for TensorRT is a little bit behind? Normally, these warnings wouldn’t show up because the build system treats them as system includes which are set to not show warnings.

I can easily solve this in CMake by simple adding the include directory as a SYSTEM one but I was just curious if this is expected.

I’ve confirmed, there’s deprecation macros on the github:

Seems like it’s a-okay then, just an internal thing for the devs.

How do we suppress these warnings?

Deprecated DimsCHW will be removed in a future version of TensorRT, use Dims3 instead.
Other option is just change the log severity to error.