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

Reduce val device transfers #7525

Merged
merged 1 commit into from
Apr 22, 2022
Merged

Reduce val device transfers #7525

merged 1 commit into from
Apr 22, 2022

Conversation

glenn-jocher
Copy link
Member

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

Reduced device transfers for data, improved speeds, reduced code.

EDIT: seems to shave about 1 second off of COCO val. Not huge but it's something!

🛠️ PR Summary

Made with ❤️ by Ultralytics Actions

🌟 Summary

Optimization of validation metrics computation in YOLOv5.

📊 Key Changes

  • Replaced Python lists with PyTorch tensors for metric computations.
  • Streamlined and simplified true positive (TP) tensor initialization.
  • Modified the handling of cases with no predictions to use the newly initialized TP tensor.
  • Changed the statistics concatenation from numpy to PyTorch, followed by a conversion to CPU numpy arrays.

🎯 Purpose & Impact

  • Increased Efficiency: By using PyTorch tensors instead of lists, validation computations should execute faster, leveraging GPU acceleration.
  • Code Simplification: The simplification of TP tensor initialization and use of tensors throughout can make the codebase easier to understand and maintain.
  • Consistency Across Devices: With changes in tensor operations, code execution becomes more consistent across different computing devices.
  • Potential Impact to Users: Users may experience reduced validation times and improved performance, especially when using GPUs.

@glenn-jocher glenn-jocher self-assigned this Apr 22, 2022
@glenn-jocher glenn-jocher merged commit d2e698c into master Apr 22, 2022
@glenn-jocher glenn-jocher deleted the reduce/val branch April 22, 2022 03:06
@hans0809
Copy link

device error after one epoch finish

@glenn-jocher
Copy link
Member Author

glenn-jocher commented Apr 22, 2022

@hans0809 👋 hi, thanks for letting us know about this possible problem with YOLOv5 🚀. I trained correctly with master just now in Colab with a V100, so I'm not able to reproduce any issues with this PR:

Screen Shot 2022-04-22 at 10 27 22 AM

We've created a few short guidelines below to help users provide what we need in order to start investigating a possible problem.

How to create a Minimal, Reproducible Example

When asking a question, people will be better able to provide help if you provide code that they can easily understand and use to reproduce the problem. This is referred to by community members as creating a minimum reproducible example. Your code that reproduces the problem should be:

  • Minimal – Use as little code as possible to produce the problem
  • Complete – Provide all parts someone else needs to reproduce the problem
  • Reproducible – Test the code you're about to provide to make sure it reproduces the problem

For Ultralytics to provide assistance your code should also be:

  • Current – Verify that your code is up-to-date with GitHub master, and if necessary git pull or git clone a new copy to ensure your problem has not already been solved in master.
  • Unmodified – Your problem must be reproducible using official YOLOv5 code without changes. Ultralytics does not provide support for custom code ⚠️.

If you believe your problem meets all the above criteria, please close this issue and raise a new one using the 🐛 Bug Report template with a minimum reproducible example to help us better understand and diagnose your problem.

Thank you! 😃

glenn-jocher added a commit that referenced this pull request Apr 22, 2022
glenn-jocher added a commit that referenced this pull request Apr 22, 2022
@glenn-jocher
Copy link
Member Author

@hans0809 good news 😃! Your original issue may now be fixed ✅ in PR #7539. 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 🚀!

BjarneKuehl pushed a commit to fhkiel-mlaip/yolov5 that referenced this pull request Aug 26, 2022
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
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.

None yet

2 participants