Tensorrt deserialize and object destruction problem

Hi,

I have the following situation (very similar to sampleMNISTAPI c++ project):

Create runtime object in construction function

nvinfer1::IRuntime* runtime = nvinfer1::createInferRuntime(gLogger);
if(!runtime)
{
std::cout << “Cannot create runtime infer” << std::endl;
}

Deserialize engine (as I said is very similat to the sampleMNISTAPI, same bufferManager and so on, but I have just to deserialize given engine)

mEngine = std::shared_ptrnvinfer1::ICudaEngine(runtime->deserializeCudaEngine((void *)modelData, modelDataSize, nullptr), samplesCommon::InferDeleter());

As a test I close the application just after exiting the build function and get the following

[02/27/2020-15:26:58] [E] [TRT] …/rtExt/cuda/cudaFusedConvActRunner.cpp (92) - Cuda Error in destroyFilterTexture: 4 (driver shutting down)
[02/27/2020-15:26:58] [E] [TRT] INTERNAL_ERROR: std::exception
[02/27/2020-15:26:58] [E] [TRT] …/rtSafe/safeRuntime.cpp (32) - Cuda Error in free: 4 (driver shutting down)
terminate called after throwing an instance of ‘nvinfer1::CudaError’
what(): std::exception

I cannot understand what is causing that error. It disappears just calling mEngine->destroy() after the creation.

That is of course not desiderable because I would use the mEngine around the code. Anyway, I would not expect such problem on smart pointer deletion, it seems correct and does work for sampleMNISTAPI.
Do you have any idea that behaviour?
I am probably missing something?

thank you

regards

aa