app developer is complaining about the long loading time trt plan file. so i decided to put the loading part at the global init phase and they should be deleted at the end of global lifetime.
As described in title, with the minimum code in attachment. when calling delete m_trtEngine; a segment fault happens.
By the way. if i put gItem in the main function, i works good.
I want to Ask
whether i could delete the context/engine/runtime with C++ RAII mechanism in a global/static instance.
This problem is not related to specific onnx file. I use the Resnet50.onnx provided by the TensorRT example package.
Use trtexec to generate trt plan file out.trt
According to the discussion here: Cuda Run time library unload, The problem is caused by calling CUDA runtime API out of main function.
This error itself won’t end up with a core dump. The core dump is caused by TensorRT. maybe the overloaded delete operator on trt engine raised the problem.
Here are 2 solutions I can see:
add a function to release the global object before end of main function.
Define your global object as a pointer. so the destructor won’t be called in the end.
Personally, I prefer the 1st way, since It cleans everything up. So I can use the code of the object at anywhere else without worrying about errors caused by destructor.