BlueMirrors/Yolov5-TensorRT

yolov5 exported onnx model unable to convert to TensorRT

lchunleo opened this issue · 3 comments

Hi

i tried a simple example of getting a pretrained yolov5 model (yolov5s.pt) and followed the steps to export as yolov5s.onnx

However, when i tried the convert function, it returns the following errors:

03/02/2022-12:56:20] [TRT] [E] 4: [network.cpp::validate::2963] Error Code 4: Internal Error (Layer Slice_4 failed validation)
Traceback (most recent call last):
File "convert.py", line 72, in
convert_onnx_to_trt(opt.weights,
File "convert.py", line 25, in convert_onnx_to_trt
convert(np.random.randint(0, 255, image_shape).astype("float"))

py", line 200, in _build_engine
trt_engine_file.write(engine.serialize())
AttributeError: 'NoneType' object has no attribute 'serialize'

Am using : python convert.py --weights yolov5s.onnx --img-size 720 1080 instead of yolov5.engine indicate in the documentation

Hi @lchunleo can you share your TensorRT and pycuda versions? Also, link to that pretrained Yolov5 weight (if it's publicly available)?

staled, closing the issue. Feel free to reopen it if needed

naga24 commented

@lchunleo Try using the trtexec utility from Tensorrt to convert onnx to trt it worked for me