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

multi-GPU for val.py #6249

Closed
1 task done
bozihu opened this issue Jan 10, 2022 · 8 comments · Fixed by #6290
Closed
1 task done

multi-GPU for val.py #6249

bozihu opened this issue Jan 10, 2022 · 8 comments · Fixed by #6290
Labels
question Further information is requested Stale Stale and schedule for closing soon

Comments

@bozihu
Copy link

bozihu commented Jan 10, 2022

Search before asking

Question

I want to use the multi-GPU to get faster inference time. When I use the comand: python -m torch.distributed.launch --nproc_per_node 2 val.py, there is a bug occur.

usage: val.py [-h] [--data DATA] [--weights WEIGHTS [WEIGHTS ...]] [--batch-size BATCH_SIZE] [--imgsz IMGSZ] [--conf-thres CONF_THRES] [--iou-thres IOU_THRES] [--task TASK] [--device DEVICE] [--workers WORKERS] [--single-cls] [--augment] [--verbose] [--save-txt] [--save-hybrid]
[--save-conf] [--save-json] [--project PROJECT] [--name NAME] [--exist-ok] [--half] [--dnn]
val.py: error: unrecognized arguments: --local_rank=1
usage: val.py [-h] [--data DATA] [--weights WEIGHTS [WEIGHTS ...]] [--batch-size BATCH_SIZE] [--imgsz IMGSZ] [--conf-thres CONF_THRES] [--iou-thres IOU_THRES] [--task TASK] [--device DEVICE] [--workers WORKERS] [--single-cls] [--augment] [--verbose] [--save-txt] [--save-hybrid]
[--save-conf] [--save-json] [--project PROJECT] [--name NAME] [--exist-ok] [--half] [--dnn]
val.py: error: unrecognized arguments: --local_rank=0
Traceback (most recent call last):
File "/home/ubuntu/.conda/envs/yolov5_obb/lib/python3.8/runpy.py", line 194, in _run_module_as_main
return _run_code(code, main_globals, None,
File "/home/ubuntu/.conda/envs/yolov5_obb/lib/python3.8/runpy.py", line 87, in _run_code
exec(code, run_globals)
File "/home/ubuntu/.conda/envs/yolov5_obb/lib/python3.8/site-packages/torch/distributed/launch.py", line 260, in
main()
File "/home/ubuntu/.conda/envs/yolov5_obb/lib/python3.8/site-packages/torch/distributed/launch.py", line 255, in main
raise subprocess.CalledProcessError(returncode=process.returncode,
subprocess.CalledProcessError: Command '['/home/ubuntu/.conda/envs/yolov5_obb/bin/python', '-u', 'val.py', '--local_rank=1']' returned non-zero exit status 2.

I want to request how to use val.py with multi-GPU?

Additional

No response

@bozihu bozihu added the question Further information is requested label Jan 10, 2022
@github-actions
Copy link
Contributor

github-actions bot commented Jan 10, 2022

👋 Hello @bozihu, 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 glenn.jocher@ultralytics.com.

Requirements

Python>=3.6.0 with all requirements.txt installed including PyTorch>=1.7. To get started:

git clone https://github.com/ultralytics/yolov5  # clone
cd yolov5
pip install -r requirements.txt  # install

Environments

YOLOv5 may be run in any of the following up-to-date verified environments (with all dependencies including CUDA/CUDNN, Python and PyTorch preinstalled):

Status

CI CPU testing

If 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.

@glenn-jocher
Copy link
Member

@bozihu val.py only supports CPU and single GPU backends. You can pass it a single GPU index, i.e. --device 0.

@wandaoyi
Copy link

Sometimes, we may use many cameras unite to detect objects. So, we want to use multi GPU to deal with the requirement. That is why we asked about the issue.

@glenn-jocher
Copy link
Member

@wandaoyi one option for Multi-GPU inference is you can initialize models on different backends with YOLOv5 PyTorch Hub models just for normal inference (not validation), i.e.:

import torch

model0 = torch.hub.load('ultralytics/yolov5', 'yolov5s', device=0)
model1 = torch.hub.load('ultralytics/yolov5', 'yolov5s', device=1)
model2 = torch.hub.load('ultralytics/yolov5', 'yolov5s', device=2)
...

Make sure you git pull or force_reload=True as we updated this code recently in #6290

@glenn-jocher glenn-jocher linked a pull request Jan 14, 2022 that will close this issue
@wandaoyi
Copy link

wandaoyi commented Jan 15, 2022 via email

@glenn-jocher
Copy link
Member

@wandaoyi I don't know, it depends on your application. You want to create a good pipeline that produces high GPU utilization rates (i.e. check with nvidia-smi) to fully use your available hardware.

@wandaoyi
Copy link

wandaoyi commented Jan 20, 2022 via email

@github-actions
Copy link
Contributor

github-actions bot commented Feb 20, 2022

👋 Hello, this issue has been automatically marked as stale because it has not had recent activity. Please note it will be closed if no further activity occurs.

Access additional YOLOv5 🚀 resources:

Access additional Ultralytics ⚡ resources:

Feel free to inform us of any other issues you discover or feature requests that come to mind in the future. Pull Requests (PRs) are also always welcomed!

Thank you for your contributions to YOLOv5 🚀 and Vision AI ⭐!

@github-actions github-actions bot added the Stale Stale and schedule for closing soon label Feb 20, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested Stale Stale and schedule for closing soon
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants