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

tensorrt 7.2.3.4 get some wrong boxes with high score,but tensort 8.2 is correct #6012

Closed
1 task done
we0091234 opened this issue Dec 17, 2021 · 18 comments · Fixed by #6021, #5699, #6185 or #6235
Closed
1 task done

tensorrt 7.2.3.4 get some wrong boxes with high score,but tensort 8.2 is correct #6012

we0091234 opened this issue Dec 17, 2021 · 18 comments · Fixed by #6021, #5699, #6185 or #6235
Labels
question Further information is requested

Comments

@we0091234
Copy link

Search before asking

Question

tensorrt 7.2.3.4 get some wrong boxes with high score,but tensort 8.2 is correct
ubuntu 16.04 tensorrt 7.2.3.4 cuda 10.2

zidane

have you tried the tensorrt 7 ?

Additional

No response

@we0091234 we0091234 added the question Further information is requested label Dec 17, 2021
@github-actions
Copy link
Contributor

github-actions bot commented Dec 17, 2021

👋 Hello @we0091234, 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 Glenn Jocher at glenn.jocher@ultralytics.com.

Requirements

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

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

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

@we0091234 thanks for raising this issue! Can you implement a version check with a warning that TensorRT produces incorrect boxes?

@glenn-jocher
Copy link
Member

@we0091234 I think this is the place:

import tensorrt as trt # https://developer.nvidia.com/nvidia-tensorrt-download

@glenn-jocher
Copy link
Member

@we0091234 good news 😃! Your original issue may now be fixed ✅ in PR #6021. This PR does not address any TRT 7 issues, but it creates a version check with a warning that TRT 8 is required by YOLOv5.

To receive this update:

  • Gitgit pull from within your yolov5/ directory or git clone https://github.com/ultralytics/yolov5 again
  • PyTorch Hub – Force-reload model = torch.hub.load('ultralytics/yolov5', 'yolov5s', force_reload=True)
  • Notebooks – View updated notebooks Open In Colab Open In Kaggle
  • Dockersudo docker pull ultralytics/yolov5:latest to update your image Docker Pulls

Thank you for spotting this issue and informing us of the problem. Please let us know if this update resolves the issue for you, and feel free to inform us of any other issues you discover or feature requests that come to mind. Happy trainings with YOLOv5 🚀!

@glenn-jocher
Copy link
Member

@we0091234 also I see different ONNX opsets are used in export.py depending on TRT version. Could ONNX Opset 12 be causing the TRT 7 issues?

yolov5/export.py

Lines 268 to 273 in 407a905

def export_engine(model, im, file, train, half, simplify, workspace=4, verbose=False, prefix=colorstr('TensorRT:')):
try:
check_requirements(('tensorrt',))
import tensorrt as trt
opset = (12, 13)[trt.__version__[0] == '8'] # test on TensorRT 7.x and 8.x

@1chimaruGin
Copy link

I tried with opset 12 and TRT 7.2.1.3, get some wrong boxes too
zidane
.

@glenn-jocher
Copy link
Member

@1chimaruGin what happens if you try opset 11 or 13 with TRT 7?

@1chimaruGin
Copy link

@glenn-jocher
With opset 11, also has wrong boxes too.
With opset 13, can't export TensorRT.

@glenn-jocher
Copy link
Member

@1chimaruGin ok, then it seems like we need to set a lower limit on TRT>=8.0 with YOLOv5. I'll consult the TRT export author and add a TODO to investigate

@glenn-jocher
Copy link
Member

@imyhxy it seems like TRT 7 export causes problems (see above).

Do you think we should implement a hard requirement for TRT 8.0 export and inference with YOLOv5? I implemented a warning (but not an error) on TRT 7 inference in #6021, but this is only a warning on inference, and does not apply to export.

@imyhxy
Copy link
Contributor

imyhxy commented Jan 4, 2022

@glenn-jocher Hi, jocher

I found out that there are some weird issues between TRT 7 and anchor_grid variable, when the anchor_grid is expanded to the feature size, the engine will output the wrong results (looks like the memory order of anchor_grid in TRT 7 is messed). I make a workround patch to the export_engine function and will not actually affect the model, check it out in #6185

.view((1, self.na, 1, 1, 2)).expand((1, self.na, ny, nx, 2)).float()

@we0091234
Copy link
Author

@imyhxy great job! It's ok now with tensorrt7.2.3.4

@glenn-jocher
Copy link
Member

@we0091234 good news 😃! Your original issue may now be fixed ✅ in PR #6185 by @imyhxy. To receive this update:

  • Gitgit pull from within your yolov5/ directory or git clone https://github.com/ultralytics/yolov5 again
  • PyTorch Hub – Force-reload model = torch.hub.load('ultralytics/yolov5', 'yolov5s', force_reload=True)
  • Notebooks – View updated notebooks Open In Colab Open In Kaggle
  • Dockersudo docker pull ultralytics/yolov5:latest to update your image Docker Pulls

Thank you for spotting this issue and informing us of the problem. Please let us know if this update resolves the issue for you, and feel free to inform us of any other issues you discover or feature requests that come to mind. Happy trainings with YOLOv5 🚀!

@we0091234
Copy link
Author

@glenn-jocher yes ,It works !

@glenn-jocher glenn-jocher removed the TODO label Jan 6, 2022
@glenn-jocher
Copy link
Member

@we0091234 great thanks! TODO removed.

@1chimaruGin
Copy link

@glenn-jocher

While exporting TRT, this error occured.

TensorRT: export failure: version 8.0.0 required by YOLOv5, but version 7.1.3.0 is currently installed

I think this line if trt.__version__[0] == "7" need to fix.

@glenn-jocher
Copy link
Member

@1chimaruGin we've been updating this section a lot recently. Can you git pull to make sure your code is up to date and retry your command?

@glenn-jocher glenn-jocher linked a pull request Jan 7, 2022 that will close this issue
@glenn-jocher
Copy link
Member

@1chimaruGin good news 😃! Your original issue may now be fixed ✅ in PR #6235. To receive this update:

  • Gitgit pull from within your yolov5/ directory or git clone https://github.com/ultralytics/yolov5 again
  • PyTorch Hub – Force-reload model = torch.hub.load('ultralytics/yolov5', 'yolov5s', force_reload=True)
  • Notebooks – View updated notebooks Open In Colab Open In Kaggle
  • Dockersudo docker pull ultralytics/yolov5:latest to update your image Docker Pulls

Thank you for spotting this issue and informing us of the problem. Please let us know if this update resolves the issue for you, and feel free to inform us of any other issues you discover or feature requests that come to mind. Happy trainings with YOLOv5 🚀!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
4 participants