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

Autoinstall TensorRT if missing #7537

Merged
merged 7 commits into from
Apr 22, 2022
Merged

Autoinstall TensorRT if missing #7537

merged 7 commits into from
Apr 22, 2022

Conversation

glenn-jocher
Copy link
Member

@glenn-jocher glenn-jocher commented Apr 22, 2022

May help resolve #7464

πŸ› οΈ PR Summary

Made with ❀️ by Ultralytics Actions

🌟 Summary

Enhanced error handling and auto-update for TensorRT in YOLOv5 export script.

πŸ“Š Key Changes

  • πŸ”’ Assert condition moved to ensure GPU presence before importing TensorRT.
  • πŸ”„ Try-except block added for handling TensorRT import errors.
  • πŸ†™ Auto-update feature added to install TensorRT if not present.

🎯 Purpose & Impact

  • πŸ› οΈ Improves user experience by providing clear instructions when a GPU is needed and not present.
  • βš™οΈ Helps users resolve TensorRT import issues with an auto-installation feature.
  • πŸ’‘ Prevents the attempt to export when requirements aren't met, avoiding potential confusion or errors, thus streamlining the export process for developers and users alike.

@glenn-jocher glenn-jocher self-assigned this Apr 22, 2022
@glenn-jocher glenn-jocher merged commit cc1d7df into master Apr 22, 2022
@glenn-jocher glenn-jocher deleted the auto/tensorrt branch April 22, 2022 19:31
except Exception:
s = f"\n{prefix} tensorrt not found and is required by YOLOv5"
LOGGER.info(f"{s}, attempting auto-update...")
r = '-U nvidia-tensorrt --index-url https://pypi.ngc.nvidia.com'
Copy link
Contributor

@zhiqwang zhiqwang Apr 23, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FYI @glenn-jocher , These wheels only works on Linux operating system and x86_64 CPU architecture with Python versions 3.6 to 3.9 and CUDA 11.x. See https://docs.nvidia.com/deeplearning/tensorrt/install-guide/index.html#installing-pip for more details. Many users use TensorRT on Windows, perhaps some explanations should be added here to prevent user annoyance when using it, such as #7009 (comment) .

Copy link
Member Author

@glenn-jocher glenn-jocher Apr 23, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@zhiqwang good point! I can't programmatically check the CUDA version, but we can check OS before install. I'll make a PR. The Python version requirement is already met as YOLOv5 requires 3.7 (may also work with 3.6, but no longer supported).

Copy link
Member Author

@glenn-jocher glenn-jocher Apr 23, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@zhiqwang all done! PR #7549 is merged that implements OS checks prior to install. This should resolve most of the problem, and migration over time to CUDA 11 should resolve the rest of the issue. I guess Python 3.10 could be an edge case though.

glenn-jocher added a commit that referenced this pull request Apr 23, 2022
May partially resolve concerns in #7537 (comment)
glenn-jocher added a commit that referenced this pull request Apr 23, 2022
BjarneKuehl pushed a commit to fhkiel-mlaip/yolov5 that referenced this pull request Aug 26, 2022
* Autoinstall TensorRT if missing

May resolve ultralytics#7464

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Update export.py

* Update export.py

* Update export.py

* Update export.py

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
BjarneKuehl pushed a commit to fhkiel-mlaip/yolov5 that referenced this pull request Aug 26, 2022
ctjanuhowski pushed a commit to ctjanuhowski/yolov5 that referenced this pull request Sep 8, 2022
* Autoinstall TensorRT if missing

May resolve ultralytics#7464

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Update export.py

* Update export.py

* Update export.py

* Update export.py

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
ctjanuhowski pushed a commit to ctjanuhowski/yolov5 that referenced this pull request Sep 8, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

tensorrt infer code
2 participants