Unable to perform inference using yolov3 in tensorrt samples

Hi,
My environment details are as under:
-OS: Ubuntu 16.04
-GPU: Geforce GTX 750 Ti
-CUDA: 9.0.176
-CuDNN: 7.5.0
-TensorRT: 5.1.5.0
-Driver: 410.104

The issue is that I want to run yolov3 on tensorrt and I am successful in running yolov3_to_onnx.py file present in tensorrt5.1.5.0/samples/python/yolov3_onnx and have produced yolov3.onnx but when I run onnx_to_tensorrt.py, I get this error:

Loading ONNX file from path yolov3.onnx…
Beginning ONNX file parsing
Completed parsing of ONNX file
Building an engine from file yolov3.onnx; this may take a while…
[TensorRT] ERROR: engine.cpp (177) - Cudnn Error in initializeCommonContext: 1 (Could not initialize cudnn, please check cudnn installation.)
[TensorRT] ERROR: engine.cpp (177) - Cudnn Error in initializeCommonContext: 1 (Could not initialize cudnn, please check cudnn installation.)
Completed creating Engine None
Traceback (most recent call last):
File “onnx_to_tensorrt.py”, line 179, in
main()
File “onnx_to_tensorrt.py”, line 150, in main
with get_engine(onnx_file_path, engine_file_path) as engine, engine.create_execution_context() as context:
File “onnx_to_tensorrt.py”, line 125, in get_engine
return build_engine()
File “onnx_to_tensorrt.py”, line 116, in build_engine
f.write(engine.serialize())
AttributeError: ‘NoneType’ object has no attribute ‘serialize’

Then I tried a different way to convert .onnx file to .engine file by onnx2trt file which i created using https://github.com/onnx/onnx-tensorrt. and when I use that engine file to get inference using the same code i.e. onnx_to_tensorrt.py, I get this error:

Reading engine from file yolov3.engine
Segmentation fault (core dumped)

This error is coming from deserialize_cuda_engine() function.

Then I also have tried for the same task using c++ code here:
https://github.com/lewes6369/TensorRT-Yolov3

I am passing yolov3.engine created using onnx2trt to (./install/runYolov3) like this:
./install/runYolov3 --input=./test.jpg --W=608 --H=608 --class=80 --enginefile=./yolov3.engine

Output is:

####### input args#######
C=3;
H=608;
W=608;
batchsize=1;
caffemodel=yolov3.caffemodel;
calib=;
class=80;
enginefile=./yolov3.engine;
evallist=;
input=./test.jpg;
mode=fp32;
nms=0.450000;
outputs=yolo-det;
prototxt=yolov3_trt.prototxt;
####### end args#######
deserializing
Х� 247965136 0x14a8df8
Segmentation fault (core dumped)

On debugging using cout statements I have found out that this segmentation fault is coming from trtnet.cpp file at this line : mTrtEngine = mTrtRunTime->deserializeCudaEngine(data.get(), length, &mTrtPluginFactory);
Х� 247965136 0x14a8df8 ---- These are the printed values of the parameters of this function i.e. data.get() , length, and &mTrtPluginFactory. 1st and third are pointers and 2nd is an integer.

I am unable to get to know that why this segmentation fault is occuring in both c++ and python codes at deserialize cuda engine functions and why I am not able to create an engine file using onnx_to_tensorrt.py file.
I am also confused with the issue that the anaconda environment I am using to run the code is having cuda version:10.1.168 and cudnn version 7.6.0 and my system is having the above mentioned cuda and cudnn versions.
Please help me, as I have tried many things but not any success in implementing this. Thanks

  • same error