Skip to content

Avoid trt deprecated api warnings shown as errors during ORT-TRT build#16035

Merged
yf711 merged 1 commit intomainfrom
yifanl/trtDeprecatedApiWarning
May 24, 2023
Merged

Avoid trt deprecated api warnings shown as errors during ORT-TRT build#16035
yf711 merged 1 commit intomainfrom
yifanl/trtDeprecatedApiWarning

Conversation

@yf711
Copy link
Copy Markdown
Contributor

@yf711 yf711 commented May 22, 2023

Description

Avoid trt deprecated api warnings shown as errors when building onnxruntime_test_all
This issue is only visible when installing trt via binaries, rather than deb/rpm pkg (CI pipelines)

[100%] Building CXX object CMakeFiles/onnxruntime_test_all.dir/home/yifanl/onnxruntime/onnxruntime/test/unittest_main/test_main.cc.o
In file included from /home/yifanl/TensorRT-8.6.0.12/include/NvInferRuntimeCommon.h:26,
                 from /home/yifanl/TensorRT-8.6.0.12/include/NvInferLegacyDims.h:16,
                 from /home/yifanl/TensorRT-8.6.0.12/include/NvInfer.h:16,
                 from /home/yifanl/onnxruntime/onnxruntime/test/unittest_main/test_main.cc:32:
/home/yifanl/TensorRT-8.6.0.12/include/NvInferRuntimeBase.h: In member function ‘virtual bool nvinfer1::IGpuAllocator::deallocate(void*)’:
/home/yifanl/TensorRT-8.6.0.12/include/NvInferRuntimeBase.h:479:26: error: ‘virtual void nvinfer1::IGpuAllocator::free(void*)’ is deprecated [-Werror=deprecated-declarations]
  479 |         this->free(memory);
      |                          ^
/home/yifanl/TensorRT-8.6.0.12/include/NvInferRuntimeBase.h:410:33: note: declared here
  410 |     TRT_DEPRECATED virtual void free(void* const memory) noexcept = 0;
      |                                 ^~~~
In file included from /home/yifanl/TensorRT-8.6.0.12/include/NvInferRuntimeCommon.h:27,
                 from /home/yifanl/TensorRT-8.6.0.12/include/NvInferLegacyDims.h:16,
                 from /home/yifanl/TensorRT-8.6.0.12/include/NvInfer.h:16,
                 from /home/yifanl/onnxruntime/onnxruntime/test/unittest_main/test_main.cc:32:
/home/yifanl/TensorRT-8.6.0.12/include/NvInferRuntimePlugin.h: At global scope:
/home/yifanl/TensorRT-8.6.0.12/include/NvInferRuntimePlugin.h:866:104: error: ‘IPluginV2’ is deprecated [-Werror=deprecated-declarations]
  866 |     virtual IPluginV2* createPlugin(AsciiChar const* name, PluginFieldCollection const* fc) noexcept = 0;
      |                                                                                                        ^
/home/yifanl/TensorRT-8.6.0.12/include/NvInferRuntimePlugin.h:97:22: note: declared here
   97 | class TRT_DEPRECATED IPluginV2
      |                      ^~~~~~~~~
/home/yifanl/TensorRT-8.6.0.12/include/NvInferRuntimePlugin.h:878:11: error: ‘IPluginV2’ is deprecated [-Werror=deprecated-declarations]
  878 |         = 0;
      |           ^
/home/yifanl/TensorRT-8.6.0.12/include/NvInferRuntimePlugin.h:97:22: note: declared here
   97 | class TRT_DEPRECATED IPluginV2
      |                      ^~~~~~~~~
In file included from /home/yifanl/TensorRT-8.6.0.12/include/NvInferRuntime.h:22,
                 from /home/yifanl/TensorRT-8.6.0.12/include/NvInfer.h:17,
                 from /home/yifanl/onnxruntime/onnxruntime/test/unittest_main/test_main.cc:32:
/home/yifanl/TensorRT-8.6.0.12/include/NvInferImpl.h:642:47: error: ‘IPluginV2’ is deprecated [-Werror=deprecated-declarations]
  642 |     virtual IPluginV2& getPlugin() noexcept = 0;
      |                                               ^
In file included from /home/yifanl/TensorRT-8.6.0.12/include/NvInferRuntimeCommon.h:27,
                 from /home/yifanl/TensorRT-8.6.0.12/include/NvInferLegacyDims.h:16,
                 from /home/yifanl/TensorRT-8.6.0.12/include/NvInfer.h:16,
                 from /home/yifanl/onnxruntime/onnxruntime/test/unittest_main/test_main.cc:32:
/home/yifanl/TensorRT-8.6.0.12/include/NvInferRuntimePlugin.h:97:22: note: declared here
   97 | class TRT_DEPRECATED IPluginV2
      |                      ^~~~~~~~~
In file included from /home/yifanl/TensorRT-8.6.0.12/include/NvInferRuntime.h:22,
                 from /home/yifanl/TensorRT-8.6.0.12/include/NvInfer.h:17,
                 from /home/yifanl/onnxruntime/onnxruntime/test/unittest_main/test_main.cc:32:
/home/yifanl/TensorRT-8.6.0.12/include/NvInferImpl.h:1008:113: error: ‘IPluginV2’ is deprecated [-Werror=deprecated-declarations]
 1008 |     virtual IPluginV2Layer* addPluginV2(ITensor* const* inputs, int32_t nbInputs, IPluginV2& plugin) noexcept = 0;
      |                                                                                                                 ^
In file included from /home/yifanl/TensorRT-8.6.0.12/include/NvInferRuntimeCommon.h:27,
                 from /home/yifanl/TensorRT-8.6.0.12/include/NvInferLegacyDims.h:16,
                 from /home/yifanl/TensorRT-8.6.0.12/include/NvInfer.h:16,
                 from /home/yifanl/onnxruntime/onnxruntime/test/unittest_main/test_main.cc:32:
/home/yifanl/TensorRT-8.6.0.12/include/NvInferRuntimePlugin.h:97:22: note: declared here
   97 | class TRT_DEPRECATED IPluginV2
      |                      ^~~~~~~~~
In file included from /home/yifanl/onnxruntime/onnxruntime/test/unittest_main/test_main.cc:32:
/home/yifanl/TensorRT-8.6.0.12/include/NvInfer.h:3647:28: error: ‘IPluginV2’ is deprecated [-Werror=deprecated-declarations]
 3647 |     IPluginV2& getPlugin() noexcept
      |                            ^~~~~~~~
In file included from /home/yifanl/TensorRT-8.6.0.12/include/NvInferRuntimeCommon.h:27,
                 from /home/yifanl/TensorRT-8.6.0.12/include/NvInferLegacyDims.h:16,
                 from /home/yifanl/TensorRT-8.6.0.12/include/NvInfer.h:16,
                 from /home/yifanl/onnxruntime/onnxruntime/test/unittest_main/test_main.cc:32:
/home/yifanl/TensorRT-8.6.0.12/include/NvInferRuntimePlugin.h:97:22: note: declared here
   97 | class TRT_DEPRECATED IPluginV2
      |                      ^~~~~~~~~
In file included from /home/yifanl/onnxruntime/onnxruntime/test/unittest_main/test_main.cc:32:
/home/yifanl/TensorRT-8.6.0.12/include/NvInfer.h:6965:88: error: ‘IFullyConnectedLayer’ is deprecated [-Werror=deprecated-declarations]
 6965 |         ITensor& input, int32_t nbOutputs, Weights kernelWeights, Weights biasWeights) noexcept
      |                                                                                        ^~~~~~~~
In file included from /home/yifanl/onnxruntime/onnxruntime/test/unittest_main/test_main.cc:32:
/home/yifanl/TensorRT-8.6.0.12/include/NvInfer.h:1518:22: note: declared here
 1518 | class TRT_DEPRECATED IFullyConnectedLayer : public ILayer
      |                      ^~~~~~~~~~~~~~~~~~~~
In file included from /home/yifanl/onnxruntime/onnxruntime/test/unittest_main/test_main.cc:32:
/home/yifanl/TensorRT-8.6.0.12/include/NvInfer.h:7542:101: error: ‘IRNNv2Layer’ is deprecated [-Werror=deprecated-declarations]
 7542 |         ITensor& input, int32_t layerCount, int32_t hiddenSize, int32_t maxSeqLen, RNNOperation op) noexcept
      |                                                                                                     ^~~~~~~~
In file included from /home/yifanl/onnxruntime/onnxruntime/test/unittest_main/test_main.cc:32:
/home/yifanl/TensorRT-8.6.0.12/include/NvInfer.h:3349:22: note: declared here
 3349 | class TRT_DEPRECATED IRNNv2Layer : public ILayer
      |                      ^~~~~~~~~~~
In file included from /home/yifanl/onnxruntime/onnxruntime/test/unittest_main/test_main.cc:32:
/home/yifanl/TensorRT-8.6.0.12/include/NvInfer.h:7617:94: error: ‘IPluginV2’ is deprecated [-Werror=deprecated-declarations]
 7617 |     IPluginV2Layer* addPluginV2(ITensor* const* inputs, int32_t nbInputs, IPluginV2& plugin) noexcept
      |                                                                                              ^~~~~~~~
In file included from /home/yifanl/TensorRT-8.6.0.12/include/NvInferRuntimeCommon.h:27,
                 from /home/yifanl/TensorRT-8.6.0.12/include/NvInferLegacyDims.h:16,
                 from /home/yifanl/TensorRT-8.6.0.12/include/NvInfer.h:16,
                 from /home/yifanl/onnxruntime/onnxruntime/test/unittest_main/test_main.cc:32:
/home/yifanl/TensorRT-8.6.0.12/include/NvInferRuntimePlugin.h:97:22: note: declared here
   97 | class TRT_DEPRECATED IPluginV2
      |                      ^~~~~~~~~
cc1plus: all warnings being treated as errors
make[2]: *** [CMakeFiles/onnxruntime_test_all.dir/build.make:4262: CMakeFiles/onnxruntime_test_all.dir/home/yifanl/onnxruntime/onnxruntime/test/unittest_main/test_main.cc.o] Error 1
make[2]: *** Waiting for unfinished jobs....
make[1]: *** [CMakeFiles/Makefile2:2289: CMakeFiles/onnxruntime_test_all.dir/all] Error 2
make: *** [Makefile:166: all] Error 2

The change is similar to existing set_property for onnxruntime_providers_tensorrt

set_property(TARGET onnxruntime_providers_tensorrt APPEND_STRING PROPERTY COMPILE_FLAGS "-Wno-deprecated-declarations")

Motivation and Context

onnxruntime/test/unittest_main/test_main.cc includes nvinfer.h, which includes deprecated trt apis and and generates warnings.
When building onnxruntime_test_all, it will show warnings as errors and block the build.

Doubts

Although this issue is visible on trt tar binaries but not on trt deb/rpm pkgs,
Their file size&hash are the same (creation time vary), regarding headers/libs installing in different ways.

tarBin pkg
997284784 Apr 26 15:15 libnvinfer_builder_resource.so.8.6.1 997284784 Apr 26 22:21 libnvinfer_builder_resource.so.8.6.1
235369632 Apr 26 15:14 libnvinfer.so.8.6.1 235369632 Apr 26 22:21 libnvinfer.so.8.6.1

@yf711 yf711 marked this pull request as ready for review May 22, 2023 17:07
@chilo-ms
Copy link
Copy Markdown
Contributor

chilo-ms commented May 22, 2023

You should check the header file to see the function declarations, for example TensorRT-8.6.1.6/include/NvInferRuntimePlugin.h in the tar file, you will see the function is deprecated as class TRT_DEPRECATED IPluginV2.
Probably check the header file in docker container as well? The error is happening in compile time, so need to check the header file that ORT builds against.

@yf711
Copy link
Copy Markdown
Contributor Author

yf711 commented May 22, 2023

You should check the header file to see the function declarations, for example TensorRT-8.6.1.6/include/NvInferRuntimePlugin.h in the tar file, you will see the function is deprecated as class TRT_DEPRECATED IPluginV2. Probably check the header file in docker container as well? The error is happening in compile time, so need to check the header file that ORT builds against.

The header file in docker trt pkg is the same as the one in trt tar binaries.
They both declared the deprecated TRT_DEPRECATED IPluginV2

@chilo-ms
Copy link
Copy Markdown
Contributor

You should check the header file to see the function declarations, for example TensorRT-8.6.1.6/include/NvInferRuntimePlugin.h in the tar file, you will see the function is deprecated as class TRT_DEPRECATED IPluginV2. Probably check the header file in docker container as well? The error is happening in compile time, so need to check the header file that ORT builds against.

The header file in docker trt pkg is the same as the one in trt tar binaries. They both declared the deprecated TRT_DEPRECATED IPluginV2

okay, we can investigate it later.
How about Windows? Does it encounter same build issue?

@yf711
Copy link
Copy Markdown
Contributor Author

yf711 commented May 24, 2023

You should check the header file to see the function declarations, for example TensorRT-8.6.1.6/include/NvInferRuntimePlugin.h in the tar file, you will see the function is deprecated as class TRT_DEPRECATED IPluginV2. Probably check the header file in docker container as well? The error is happening in compile time, so need to check the header file that ORT builds against.

The header file in docker trt pkg is the same as the one in trt tar binaries. They both declared the deprecated TRT_DEPRECATED IPluginV2

okay, we can investigate it later. How about Windows? Does it encounter same build issue?

Building under windows has no issue

@yf711 yf711 merged commit 105f5f0 into main May 24, 2023
@yf711 yf711 deleted the yifanl/trtDeprecatedApiWarning branch May 24, 2023 20:19
mszhanyi added a commit that referenced this pull request May 25, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants