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

Set torch.cuda.manual_seed_all() for DDP #8688

Merged
merged 3 commits into from
Jul 23, 2022
Merged

Conversation

glenn-jocher
Copy link
Member

@glenn-jocher glenn-jocher commented Jul 23, 2022

πŸ› οΈ PR Summary

Made with ❀️ by Ultralytics Actions

🌟 Summary

Enhanced reproducibility in model training by ensuring consistent random seed settings.

πŸ“Š Key Changes

  • Uncommented the setting of PYTHONHASHSEED to ensure a fixed hash seed.
  • Reactivated CUDA random seed settings with torch.cuda.manual_seed and torch.cuda.manual_seed_all for single and multi-GPU setups.

🎯 Purpose & Impact

  • 🎲 Consistency: These changes guarantee that experiments with the same seed are reproducible, which is critical for research and benchmarking.
  • πŸ— Stability: Ensuring deterministic behavior improves the stability of models when trying to replicate results across different runs.
  • πŸ“ˆ Multi-GPU Support: By setting seeds for all GPUs, this ensures that multi-GPU training sessions behave more predictably.

@glenn-jocher glenn-jocher self-assigned this Jul 23, 2022
@glenn-jocher glenn-jocher merged commit 7f7bd6f into master Jul 23, 2022
@glenn-jocher glenn-jocher deleted the glenn-jocher-patch-1 branch July 23, 2022 16:24
@UnglvKitDe
Copy link
Contributor

@glenn-jocher I looked at it. Right now I also have no idea what is missing. I will think about it.

ctjanuhowski pushed a commit to ctjanuhowski/yolov5 that referenced this pull request Sep 8, 2022
* Set `torch.cuda.manual_seed_all()` for DDP

* Update general.py

* Update general.py
@glenn-jocher
Copy link
Member Author

@UnglvKitDe got it, thanks for looking into it! Let me know if you need any further assistance.

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