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

ultralytics 8.2.16 DDP pretrained argument fix #11787

Merged
merged 15 commits into from
May 15, 2024

Conversation

comlhj1114
Copy link
Contributor

@comlhj1114 comlhj1114 commented May 9, 2024

This PR solves an issue (#11769), which is related to loading a pretrained model in multi-gpu training.

I solved the problem by using the "pretrained" argument and modifying setup_model function in BaseTrainer to load a pretrained weight.

πŸ› οΈ PR Summary

Made with ❀️ by Ultralytics Actions

🌟 Summary

Enhancements and bug fixes in the Ultralytics framework, bringing it to version 8.2.16.

πŸ“Š Key Changes

  • πŸ“– Tutorial notebook (tutorial.ipynb) cleaned up to remove error messages related to cuDNN, cuFFT, and cuBLAS registration failures.
  • πŸ†™ Framework version bump in __init__.py from 8.2.15 to 8.2.16.
  • πŸ”¨ In trainer.py, improved model setup logic by refining the handling of configuration files and pretrained weights, ensuring that the correct setup path is chosen based on the input.

🎯 Purpose & Impact

  • πŸš€ Tutorial Clarity: Removing error messages from the tutorial notebook ensures a smoother learning experience for new users, making the educational content clearer and more accessible.
  • ✨ Framework Updates: The version increment signifies improvements and possibly new features or bug fixes, contributing to the overall maturity and stability of the Ultralytics framework.
  • πŸ›  Model Setup Enhancements: Changes to the model setup improve the framework's flexibility and ease of use. Users can now expect a more straightforward and error-resistant process when loading models with predefined weights or configurations, facilitating both development and deployment workflows.

Copy link

github-actions bot commented May 9, 2024

All Contributors have signed the CLA. βœ…
Posted by the CLA Assistant Lite bot.

@comlhj1114
Copy link
Contributor Author

I have read the CLA Document and I sign the CLA

Copy link

@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 @comlhj1114, thank you for submitting an Ultralytics YOLOv8 πŸš€ 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/ultralytics main 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 main locally.
  • βœ… Verify all YOLOv8 Continuous Integration (CI) checks are passing.
  • βœ… Update YOLOv8 Docs for any new or updated features.
  • βœ… 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

See our Contributing Guide for details and let us know if you have any questions!

Copy link

codecov bot commented May 9, 2024

Codecov Report

Attention: Patch coverage is 80.00000% with 1 lines in your changes are missing coverage. Please review.

Project coverage is 70.60%. Comparing base (590002f) to head (16fcda2).

❗ Current head 16fcda2 differs from pull request most recent head 894e160. Consider uploading reports for the commit 894e160 to get more accurate results

Files Patch % Lines
ultralytics/engine/trainer.py 80.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #11787      +/-   ##
==========================================
- Coverage   74.77%   70.60%   -4.18%     
==========================================
  Files         122      122              
  Lines       15634    15632       -2     
==========================================
- Hits        11691    11037     -654     
- Misses       3943     4595     +652     
Flag Coverage Ξ”
Benchmarks 35.50% <0.00%> (-0.05%) ⬇️
GPU 37.28% <60.00%> (-5.64%) ⬇️
Tests 66.75% <80.00%> (-3.70%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

β˜” View full report in Codecov by Sentry.
πŸ“’ Have feedback on the report? Share it here.

@comlhj1114
Copy link
Contributor Author

I have read the CLA Document and I sign the CLA

@glenn-jocher
Copy link
Member

@Laughing-q can you review this proposed fix? Is it necessary? Thanks!

@glenn-jocher glenn-jocher added the TODO Items that needs completing label May 10, 2024
@glenn-jocher glenn-jocher linked an issue May 11, 2024 that may be closed by this pull request
2 tasks
@Laughing-q
Copy link
Member

@glenn-jocher yes I tested and confirmed pretrained arg does not work when using DDP mode.
@comlhj1114 Hi, I updated the PR a little bit and tested pretrained arg with DDP mode locally, everything works to me! Can you test the PR again to see if it still works to you? Thanks!
BTW here's my test command which aims to load yolov8n.pt by pretrained=yolov8n.pt for a quick verification:

yolo detect train data=coco128.yaml model=yolov8n.yaml pretrained=yolov8n.pt device=0,1

and it got exactly the same results as directly loading model by model=yolov8n.pt:

yolo detect train data=coco128.yaml model=yolov8n.pt

which means yolov8n.pt is loaded successfully in the first command.

@Burhan-Q Burhan-Q added the enhancement New feature or request label May 13, 2024
@johnnynunez
Copy link
Contributor

I've checked and it's true. There are differences.
image

@Laughing-q
Copy link
Member

@johnnynunez is the one with dark blue that trained with pretrained? if so then I think the updates are working!

@johnnynunez
Copy link
Contributor

johnnynunez commented May 15, 2024

@johnnynunez is the one with dark blue that trained with pretrained? if so then I think the updates are working!

Both are pretrained. But Blue is applying the changes of PR
image

@Laughing-q
Copy link
Member

@johnnynunez got it! Thanks! Then it means the PR is working!
@glenn-jocher I think the PR is ready! @johnnynunez tested it as well for double check!

@glenn-jocher
Copy link
Member

@Laughing-q @johnnynunez awesome, thanks guys!

@glenn-jocher glenn-jocher changed the title Fix/ddp pretrained ultralytics 8.2.16 DDP pretrained argument fix May 15, 2024
@glenn-jocher glenn-jocher merged commit b87ea6a into ultralytics:main May 15, 2024
13 checks passed
@glenn-jocher
Copy link
Member

@comlhj1114 PR merged! Thank you for your contributions. Please let us know if you spot any other areas we could improve :)

@glenn-jocher glenn-jocher removed the TODO Items that needs completing label May 15, 2024
gkinman pushed a commit to Octasic/ultralytics that referenced this pull request May 30, 2024
Co-authored-by: UltralyticsAssistant <web@ultralytics.com>
Co-authored-by: Glenn Jocher <glenn.jocher@ultralytics.com>
Co-authored-by: Laughing-q <1185102784@qq.com>
Co-authored-by: Laughing <61612323+Laughing-q@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

In DDP, pretrained model won't be loaded.
6 participants