diff --git a/src/runtime/contrib/tensorrt/tensorrt_runtime.cc b/src/runtime/contrib/tensorrt/tensorrt_runtime.cc index 3f87f8d00ee6..e28c5a8c61d0 100644 --- a/src/runtime/contrib/tensorrt/tensorrt_runtime.cc +++ b/src/runtime/contrib/tensorrt/tensorrt_runtime.cc @@ -109,6 +109,14 @@ class TensorRTRuntime : public JSONRuntimeBase { } #ifdef TVM_GRAPH_RUNTIME_TENSORRT + /*! \brief Destroy engines and contexts. */ + ~TensorRTRuntime() { + for (auto& it : trt_engine_cache_) { + it.second.context->destroy(); + it.second.engine->destroy(); + } + } + /*! \brief Run inference using built engine. */ void Run() override { BuildEngine();