Tensorrt 5.1 c++ api cannot deserialize retinanet trt engine


I met some problem with Tensorrt 5.1 c++ api. I use 5.1 python api to convert a retinanet onnx model to tensorrt engine and serialize it. When I tried to deserialize it using c++ api I met the following error:
getPluginCreator could not find plugin ResizeNearest version 001 namespace
Cannot deserialize plugin ResizeNearest

The serialize code is:
with trt.OnnxParser(network, TRT_LOGGER) as parser:
with open(os.path.join(net_folder, ‘model.onnx’), ‘rb’) as model:
if not parser.parse(model.read()):
logging.info(‘onnx parser failed!’)
return False
engine = builder.build_cuda_engine(network)
with open(engine_file, ‘wb’) as f:

deserialize code is :
IRuntime* runtime = createInferRuntime(logger);
_cuda_engine = runtime->deserializeCudaEngine(engine_buf,

The error is strange because ResizeNearest is the op name in caffe2 retinanet model, in ONNX format it is called Upsample. And I can also use tensorrt 5.1 python api to deserialize it and do inference properly. Is there a gap between c++ api and python api or I missed linking some library?

Pls give some hints. Thanks!

I figured it out.
For C++ api, just inlucde <NVOnnxParserRuntime.h> and then deserialize by
_cuda_engine = runtime->deserializeCudaEngine(engine_buf,
Somehow the ResizeNearest plugin is implemented in tensorrt onnx parser, I guess.

1 Like


HI,zhangxiong,I meet the same case, did you slove this problem?

Thanks for your answer
I solved this problem