- Name: NVIDIA Jetson
- Type: AGX Xavier
- Jetpack: UNKNOWN [L4T 32.2.2] (JetPack 4.3. DP)
- GPU-Arch: 7.2
- Libraries:
- CUDA: 10.0.326
- cuDNN: 7.6.3.28-1+cuda10.0
- TensorRT: 6.0.1.5-1+cuda10.0
- VisionWorks: NOT_INSTALLED
- OpenCV: 4.0.0 compiled CUDA: YES
Hi,
I want to connect BatchedNMSPlugin to my detector model.
So, I convert onnx file to trt and connect to batchedNMSPlugin.
I change onnx2trt’s main.cpp.
[main.cpp]
// set nms paramter
nvinfer1::plugin::NMSParameters nms_parameter;
nms_parameter.shareLocation = true;
nms_parameter.backgroundLabelId = -1;
nms_parameter.numClasses = 1;
nms_parameter.scoreThreshold = 0.1f;
nms_parameter.iouThreshold = 0.5f;
nms_parameter.isNormalized = false;
nms_parameter.keepTopK = 100;
// create nms plugin
nvinfer1::IPluginV2* nms_plugin = createBatchedNMSPlugin(nms_parameter);
// set nms input tensor
// 7: outputs_bbox0
// 8: outputs_score0
nvinfer1::ITensor* nms_input_tensors[] = {trt_network->getOutput(7), trt_network->getOutput(8)};
// print nms input tensor
for (auto i = 0; i < 2; ++i) {
auto dims = nms_input_tensors[i]->getDimensions();
cout << i << ": " << dims.nbDims << ": ";
for (auto j = 0; j < dims.nbDims; ++j)
cout << dims.d[j] << ", ";
cout << endl;
}
// connect to original network
auto nms_layer = trt_network->addPluginV2(&nms_input_tensors[0], 2, *nms_plugin);
// set nms output tensor
for (auto i = 0; i < nms_layer->getNbOutputs(); ++i)
trt_network->markOutput(*(nms_layer->getOutput(i)));
// print nms output tensor
for (auto i = 0; i < nms_layer->getNbOutputs(); ++i) {
auto dims = nms_layer->getOutput(i)->getDimensions();
cout << i << ": " << dims.nbDims << ": ";
for (auto j = 0; j < dims.nbDims; ++j)
cout << dims.d[j] << ", ";
cout << endl;
}
// remove original detector's output
trt_network->unmarkOutput(*(trt_network->getOutput(7)));
trt_network->unmarkOutput(*(trt_network->getOutput(7)));
// set nms output's name
char* nms_output_name[] = {"num_detections", "nmsed_boxes", "nmsed_scores", "nmsed_classes"};
for (auto i = 0; i < 4; ++i)
trt_network->getOutput(7 + i)->setName(nms_output_name[i]);
// final nms engine's output
for (auto i = 0; i < trt_network->getNbOutputs(); ++i) {
auto nms_tensor = trt_network->getOutput(i);
auto nms_out_dims = nms_tensor->getDimensions();
cout << i << ": " << nms_tensor->getName() << ": ";
for (auto j = 0; j < nms_out_dims.nbDims; ++j)
cout << nms_out_dims.d[j] << ", ";
cout << endl;
}
So, I can get Tensor RT engine file from converted by onnx2trt.
And I want to use this engine file another source.
I want to deserialize this engine and execute engine.
But In this case, I got the error on deserializeCudaEngine().
INVALID_ARGUMENT: getPluginCreator could not find plugin BatchedNMS_TRT version 1
safeDeserializationUtils.cpp (259) - Serialization Error in load: 0 (Cannot deserialize plugin since corresponding IPluginCreator not found in Plugin Registry)
INVALID_STATE: std::exception
INVALID_CONFIG: Deserialize the cuda engine failed.
Segmentation fault (core dumped)
How can I do?
Thanks.