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

Update torch.cuda.amp to torch.amp #13244

Open
wants to merge 18 commits into
base: master
Choose a base branch
from

Conversation

jacobdbrown4
Copy link

@jacobdbrown4 jacobdbrown4 commented Aug 5, 2024

torch.cuda.amp is deprecated as of Pytorch 2.4. This PR updates use to torch.amp. This gets rid of the

FutureWarning: `torch.cuda.amp.autocast(args...)` is deprecated. Please use `torch.amp.autocast('cuda', args...)` instead.
  with torch.cuda.amp.autocast(amp):

warning as mentioned in #13226.

🛠️ PR Summary

Made with ❤️ by Ultralytics Actions

🌟 Summary

Update to use latest CUDA AMP (Automatic Mixed Precision) API across various files for better compatibility and performance.

📊 Key Changes

  • Replaced torch.cuda.amp.autocast with torch.amp.autocast("cuda") in multiple files.
  • Replaced torch.cuda.amp.GradScaler with torch.amp.GradScaler("cuda").

🎯 Purpose & Impact

  • Improved Compatibility: Ensures that the code remains compatible with the latest PyTorch changes, reducing the risk of future issues.
  • Performance: Leverages CUDA's improved automatic mixed precision to potentially enhance computational efficiency.
  • Maintenance: Simplifies code adjustments related to AMP, making future updates easier to manage.

Copy link
Contributor

github-actions bot commented Aug 5, 2024

All Contributors have signed the CLA. ✅
Posted by the CLA Assistant Lite bot.

@UltralyticsAssistant UltralyticsAssistant added enhancement New feature or request python Pull requests that update Python code labels Aug 5, 2024
Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

👋 Hello @jacobdbrown4, thank you for submitting a YOLOv5 🚀 PR! To allow your work to be integrated as seamlessly as possible, we advise you to:

  • ✅ Verify your PR is up-to-date with ultralytics/yolov5 master branch. If your PR is behind you can update your code by clicking the 'Update branch' button or by running git pull and git merge master locally.
  • ✅ Verify all YOLOv5 Continuous Integration (CI) checks are passing.
  • ✅ Reduce changes to the absolute minimum required for your bug fix or feature addition. "It is not daily increase but daily decrease, hack away the unessential. The closer to the source, the less wastage there is." — Bruce Lee

@jacobdbrown4
Copy link
Author

I have read the CLA Document and I sign the CLA

@jacobdbrown4
Copy link
Author

recheck

@glenn-jocher
Copy link
Member

@jacobdbrown4 thank you for your comment! To ensure we address your issue effectively, could you please verify that you are using the latest versions of YOLOv5 and all related dependencies? This helps us confirm whether the problem persists with the most recent updates.

If the issue is still reproducible, please provide additional details such as error messages, steps to reproduce, and any relevant code snippets. This information will help us diagnose and resolve the issue more efficiently.

Looking forward to your response! 😊

@ijnrghjkdsmigywneig203
Copy link

ijnrghjkdsmigywneig203 commented Sep 13, 2024

This pull request needs to be merged, inference times are slower due to this error constantly popping up with the newest versions of pytorch.

@ijnrghjkdsmigywneig203
Copy link

@glenn-jocher

@glenn-jocher
Copy link
Member

Thank you for your input. Please ensure you're using the latest YOLOv5 version to see if the issue persists. If the problem continues, provide additional details so we can assist further.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request python Pull requests that update Python code
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants