diff --git a/paddle/fluid/inference/tensorrt/engine.cc b/paddle/fluid/inference/tensorrt/engine.cc index e77e12713ca202b0f28198fcaba3dae2bd5ad1fa..d9e87122ac258ceec08fa623f65a375dc0999da4 100644 --- a/paddle/fluid/inference/tensorrt/engine.cc +++ b/paddle/fluid/inference/tensorrt/engine.cc @@ -217,8 +217,17 @@ 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(