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

Fix: Update torch.cuda.amp to torch.amp to Resolve Deprecation Warning #13482

Conversation

Bala-Vignesh-Reddy
Copy link

@Bala-Vignesh-Reddy Bala-Vignesh-Reddy commented Jan 5, 2025

πŸ› οΈ PR Summary

Made with ❀️ by Ultralytics Actions

🌟 Summary

Updated the implementation of PyTorch Automatic Mixed Precision (AMP) across various YOLOv5 scripts to use the newer torch.amp API for CUDA operations. πŸ–₯️⚑

πŸ“Š Key Changes

  • Replaced instances of torch.cuda.amp.autocast with torch.amp.autocast("cuda", enabled=...) throughout the codebase for compatibility with the updated PyTorch API.
  • Updated AMP-related functionality (e.g., GradScaler) to align with the new torch.amp API.
  • Adjusted multiple files, including train.py, segment/train.py, classify/val.py, and others, to make consistent use of the new API.

🎯 Purpose & Impact

  • Purpose: This update ensures compatibility with the latest versions of PyTorch, aligning with their updated AMP APIs and practices. This enhances maintainability and future-proofing of the YOLOv5 codebase. πŸš€
  • Impact: Users should experience smoother performance with improved compatibility when using newer PyTorch releases. Fluid utilization of mixed precision training can speed up training and inference while reducing computational costs. ⚑

Copy link
Contributor

github-actions bot commented Jan 5, 2025


Thank you for your submission, we really appreciate it. Like many open-source projects, we ask that you all sign our Contributor License Agreement before we can accept your contribution. You can sign the CLA by just posting a Pull Request Comment same as the below format.


I have read the CLA Document and I sign the CLA


1 out of 2 committers have signed the CLA.
βœ… (UltralyticsAssistant)[https://github.com/UltralyticsAssistant]
❌ @Bala-Vignesh-Reddy
You can retrigger this bot by commenting recheck in this Pull Request. Posted by the CLA Assistant Lite bot.

@UltralyticsAssistant UltralyticsAssistant added bug Something isn't working dependencies Dependencies and packages enhancement New feature or request labels Jan 5, 2025
@UltralyticsAssistant
Copy link
Member

πŸ‘‹ Hello @Bala-Vignesh-Reddy, thank you for submitting a ultralytics/yolov5 πŸš€ PR! To ensure a smooth integration of your contributions, please take a moment to review the following checklist:

  • βœ… Define a Purpose: Ensure your PR description clearly explains the purpose of your changes and links to any relevant issues. Your summary has done a great job outlining the motivation, but linking any associated issues (if applicable) can provide added context.
  • βœ… Synchronize with Source: Verify that your PR is synchronized with the ultralytics/yolov5 main branch to avoid potential merge conflicts. If it's out of sync, click the 'Update branch' button or run git pull and git merge main locally.
  • βœ… Ensure CI Checks Pass: Confirm that all Ultralytics Continuous Integration (CI) checks pass. If CI checks fail, review the error logs and make necessary adjustments to resolve any issues.
  • βœ… Update Documentation: Please check if any documentation updates are required due to this change and ensure they are included, if applicable.
  • βœ… Add Tests: If applicable, verify that sufficient test cases are added or updated to cover the changes introduced in your PR, ensuring all tests pass successfully.
  • βœ… Sign the CLA: If this is your first contribution to Ultralytics, make sure to sign our Contributor License Agreement (CLA) by adding a comment with the text: I have read the CLA Document and I sign the CLA.
  • βœ… Minimize Changes: Please double-check that your updates are as minimal as possible while achieving the goal of your PR. Adhering to a clean and focused commit history helps improve reviewability. β€œSimplicity is the ultimate sophistication.” β€” Leonardo da Vinci

This is an automated response to acknowledge your effort. Rest assured that an Ultralytics engineer will review your PR in detail and provide further assistance shortly. If you have additional questions or updates, feel free to comment below. 🌟

For guidance on contributing, please see our Contributing Guide. We truly appreciate your contribution to improving YOLOv5! πŸ™Œ

@Bala-Vignesh-Reddy Bala-Vignesh-Reddy changed the title Fix: Update torch.cuda.amp to torch.amp to Resolve Deprecation Warning (#13226) Fix: Update torch.cuda.amp to torch.amp to Resolve Deprecation Warning Jan 5, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working dependencies Dependencies and packages enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants