Skip to content

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

Merged
glenn-jocher merged 3 commits intomasterfrom
glenn-jocher-patch-1
Jul 23, 2022
Merged

Set torch.cuda.manual_seed_all() for DDP#8688
glenn-jocher merged 3 commits intomasterfrom
glenn-jocher-patch-1

Conversation

@glenn-jocher
Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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.

2 participants