Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Yolov5 TensorRT inference error #7977

Closed
1 of 2 tasks
RohitSingh1226 opened this issue May 25, 2022 · 4 comments
Closed
1 of 2 tasks

Yolov5 TensorRT inference error #7977

RohitSingh1226 opened this issue May 25, 2022 · 4 comments
Labels
bug Something isn't working

Comments

@RohitSingh1226
Copy link

Search before asking

  • I have searched the YOLOv5 issues and found no similar bug report.

YOLOv5 Component

PyTorch Hub, Other

Bug

C:\Users\manas\OneDrive\Desktop\yolov5>python detect.py --weights yolov5s.engine --view-img --device 0

detect: weights=['yolov5s.engine'], source=data\images, data=data\coco128.yaml, imgsz=[640, 640],

YOLOv5 v6.1-223-g1dcb774 Python-3.9.5 torch-1.7.1+cu110 CUDA:0 (NVIDIA GeForce GTX 1650 SUPER, 4096MiB)

Loading yolov5s.engine for TensorRT inference...
[05/25/2022-16:22:26] [TRT] [I] [MemUsageChange] Init CUDA: CPU +473, GPU +0, now: CPU 7387, GPU 949 (MiB)
[05/25/2022-16:22:26] [TRT] [I] Loaded engine size: 16 MiB
[05/25/2022-16:22:26] [TRT] [I] [MemUsageSnapshot] deserializeCudaEngine begin: CPU 7403 MiB, GPU 949 MiB
[05/25/2022-16:22:26] [TRT] [E] 1: [stdArchiveReader.cpp::nvinfer1::rt::StdArchiveReader::StdArchiveReader::40] Error Code 1: Serialization (Serialization assertion stdVersionRead == serializationVersion failed.Version tag does not match. Note: Current Version: 205, Serialized Engine Version: 213)
[05/25/2022-16:22:26] [TRT] [E] 4: [runtime.cpp::nvinfer1::Runtime::deserializeCudaEngine::50] Error Code 4: Internal Error (Engine deserialization failed.)
Traceback (most recent call last):
File "C:\Users\manas\OneDrive\Desktop\yolov5\detect.py", line 252, in
main(opt)
File "C:\Users\manas\OneDrive\Desktop\yolov5\detect.py", line 247, in main
run(**vars(opt))
File "C:\Users\manas\miniconda3\lib\site-packages\torch\autograd\grad_mode.py", line 26, in decorate_context
return func(*args, **kwargs)
File "C:\Users\manas\OneDrive\Desktop\yolov5\detect.py", line 92, in run
model = DetectMultiBackend(weights, device=device, dnn=dnn, data=data, fp16=half)
File "C:\Users\manas\OneDrive\Desktop\yolov5\models\common.py", line 384, in init
for index in range(model.num_bindings):
AttributeError: 'NoneType' object has no attribute 'num_bindings'

Environment

YOLO: YOLOv5 v6.1-223-g1dcb774 torch:1.7.1+cu11.0 (built in with cuda support ) Python:3.9
OS: Windows 10.
GPU: Nvidia 1650 gtx super

Minimal Reproducible Example

I used the NVIDIA Tensort package from their website, and I successfully installed using their zip, then I ran the google collab notebook to get the yolov5.engine file. I obtained the file by running a python export.py.

Once I had that file. Without making any changes to the detect.py I ran the code python detect.py --weights yolov5s.engine --view-img --device 0. My GPU details I can see in the log which means tensorRT has initialized. But then it crashes. I could use some help solving this bug

Additional

A lot of people run it on linux. Due to lack of people running it on windows, there is no one with which I can confer and get help regarding the issue. Any help would be much appreciated

Are you willing to submit a PR?

  • Yes I'd like to help by submitting a PR!
@RohitSingh1226 RohitSingh1226 added the bug Something isn't working label May 25, 2022
@github-actions
Copy link
Contributor

github-actions bot commented May 25, 2022

👋 Hello @RohitSingh1226, thank you for your interest in YOLOv5 🚀! Please visit our ⭐️ Tutorials to get started, where you can find quickstart guides for simple tasks like Custom Data Training all the way to advanced concepts like Hyperparameter Evolution.

If this is a 🐛 Bug Report, please provide screenshots and minimum viable code to reproduce your issue, otherwise we can not help you.

If this is a custom training ❓ Question, please provide as much information as possible, including dataset images, training logs, screenshots, and a public link to online W&B logging if available.

For business inquiries or professional support requests please visit https://ultralytics.com or email support@ultralytics.com.

Requirements

Python>=3.7.0 with all requirements.txt installed including PyTorch>=1.7. To get started:

git clone https://github.com/ultralytics/yolov5  # clone
cd yolov5
pip install -r requirements.txt  # install

Environments

YOLOv5 may be run in any of the following up-to-date verified environments (with all dependencies including CUDA/CUDNN, Python and PyTorch preinstalled):

Status

CI CPU testing

If this badge is green, all YOLOv5 GitHub Actions Continuous Integration (CI) tests are currently passing. CI tests verify correct operation of YOLOv5 training (train.py), validation (val.py), inference (detect.py) and export (export.py) on macOS, Windows, and Ubuntu every 24 hours and on every commit.

@glenn-jocher
Copy link
Member

@RohitSingh1226 TRT models must be exported on the same GPU and system they will run inference on.

@MrMegaMango
Copy link

I have the same issue loading TRT on the same machine that built it

@glenn-jocher
Copy link
Member

@MrMegaMango please ensure you're using the latest YOLOv5 version and TensorRT. If the issue persists, try rebuilding the engine with the same CUDA and TensorRT versions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants