-
-
Notifications
You must be signed in to change notification settings - Fork 16.7k
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
CUDA device index error in distributed training #5111
Comments
👋 Hello @qiningonline, thank you for your interest in YOLOv5 🚀! Please visit our ⭐️ Tutorials to get started, where you can find quickstart guides for simple tasks like Custom Data Training all the way to advanced concepts like Hyperparameter Evolution. If this is a 🐛 Bug Report, please provide screenshots and minimum viable code to reproduce your issue, otherwise we can not help you. If this is a custom training ❓ Question, please provide as much information as possible, including dataset images, training logs, screenshots, and a public link to online W&B logging if available. For business inquiries or professional support requests please visit https://ultralytics.com or email Glenn Jocher at [email protected]. RequirementsPython>=3.6.0 with all requirements.txt installed including PyTorch>=1.7. To get started: $ git clone https://github.com/ultralytics/yolov5
$ cd yolov5
$ pip install -r requirements.txt EnvironmentsYOLOv5 may be run in any of the following up-to-date verified environments (with all dependencies including CUDA/CUDNN, Python and PyTorch preinstalled):
StatusIf this badge is green, all YOLOv5 GitHub Actions Continuous Integration (CI) tests are currently passing. CI tests verify correct operation of YOLOv5 training (train.py), validation (val.py), inference (detect.py) and export (export.py) on MacOS, Windows, and Ubuntu every 24 hours and on every commit. |
@qiningonline thanks for the bug report! Distributed DDP may have issues as our own internal Ultralytics DDP trainings are limited to a single node so far. This means I can't verify multi-node fix results on our side, so we will have to rely on your results. If the above changes solve the problem for you in multi-node environment then please submit a PR with these changes. Also please verify the changes have no impact on single-node trainings. The simplest way to do this would be to train 2 single-node DDP models (with master branch and PR branch), i.e. using the command below and comparing final mAPs and training times. $ python -m torch.distributed.launch --nproc_per_node 4 --master_port 1 train.py --batch 64 --data coco.yaml --cfg --yolov5s.yaml weights '' --epochs 10 --device 0,1,2,3 NOTE: RNG seeds are very important for DDP (they should be different across all RANKs, and in your case across all nodes too possibly, otherwise augmentation will be identical and cause overfitting and reduced final mAP). I think this line is fine the way it is, but you should also verify seeds are set differently everywhere: Line 101 in 276b674
|
@qiningonline also you might want to migrate from |
Thank you for your comments! The changes proposed in the issue description tested and fixed the problem. Given your suggestion above, I ran the following 4 tests Test-0
Test-1
Test-2
Test-3
The metric in comparison PR added here, #5114, please help to code review when you have a moment. Thank you! |
@qiningonline awesome, thanks for the tests. The results look good. P and R noise is expected since these evaluate at a specific confidence, so less statistics than the mAPs that evaluate at all confidences. Small mAP differences are also expected as results are typically not perfectly reproducible in pytorch. |
Question
When running the distributed training, the following line is reporting a CUDA device index error
yolov5/utils/torch_utils.py
Line 37 in 276b674
Sample script when launching the training
All instances have the sample number of GPU per machine.
When running the script above,
Proposed fix: changing the following lines from
RANK
toLOCAL_RANK
[1]
yolov5/train.py
Line 102 in 276b674
[2]
yolov5/train.py
Line 114 in 276b674
[3]
yolov5/train.py
Line 211 in 276b674
Context info:
Question:
The text was updated successfully, but these errors were encountered: