From c04ea446a80e4569c7c886c575b3b4da7948d99c Mon Sep 17 00:00:00 2001 From: zlsh80826 Date: Mon, 26 Jul 2021 16:57:24 +0000 Subject: [PATCH 1/2] trt buildEngineWithConfig is deprecated --- paddle/fluid/inference/tensorrt/engine.cc | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/paddle/fluid/inference/tensorrt/engine.cc b/paddle/fluid/inference/tensorrt/engine.cc index e77e12713ca202..cce2c80476e2b1 100644 --- a/paddle/fluid/inference/tensorrt/engine.cc +++ b/paddle/fluid/inference/tensorrt/engine.cc @@ -217,8 +217,12 @@ void TensorRTEngine::FreezeNetwork() { } #endif } - infer_engine_.reset(infer_builder_->buildEngineWithConfig( + + infer_ptr plan(infer_builder_->buildSerializedNetwork( *network(), *infer_builder_config_)); + infer_ptr runtime(createInferRuntime(&logger_)); + infer_engine_.reset( + runtime->deserializeCudaEngine(plan->data(), plan->size())); PADDLE_ENFORCE_NOT_NULL( infer_engine_, platform::errors::Fatal( From 47fde05ad9e2aba9570faa5b1d8a6d5bcace4cdd Mon Sep 17 00:00:00 2001 From: zlsh80826 Date: Mon, 26 Jul 2021 17:22:21 +0000 Subject: [PATCH 2/2] add trt version control --- paddle/fluid/inference/tensorrt/engine.cc | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/paddle/fluid/inference/tensorrt/engine.cc b/paddle/fluid/inference/tensorrt/engine.cc index cce2c80476e2b1..d9e87122ac258c 100644 --- a/paddle/fluid/inference/tensorrt/engine.cc +++ b/paddle/fluid/inference/tensorrt/engine.cc @@ -218,11 +218,16 @@ void TensorRTEngine::FreezeNetwork() { #endif } +#if IS_TRT_VERSION_LT(8000) + infer_engine_.reset(infer_builder_->buildEngineWithConfig( + *network(), *infer_builder_config_)); +#else infer_ptr plan(infer_builder_->buildSerializedNetwork( *network(), *infer_builder_config_)); infer_ptr runtime(createInferRuntime(&logger_)); infer_engine_.reset( runtime->deserializeCudaEngine(plan->data(), plan->size())); +#endif PADDLE_ENFORCE_NOT_NULL( infer_engine_, platform::errors::Fatal(