Skip to content

Commit

Permalink
[Feat] Adding pytorch DDP script of detection task (#1777)
Browse files Browse the repository at this point in the history
  • Loading branch information
sarjil77 authored Nov 22, 2024
1 parent b53517a commit c3ec3cb
Show file tree
Hide file tree
Showing 2 changed files with 540 additions and 0 deletions.
21 changes: 21 additions & 0 deletions references/detection/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,27 @@ or PyTorch:
```shell
python references/detection/train_pytorch.py db_resnet50 --train_path path/to/your/train_set --val_path path/to/your/val_set --epochs 5
```
### Multi-GPU support (PyTorch only)

Multi-GPU support on Detection task with PyTorch has been added.
Arguments are the same than the ones from single GPU, except:

- `--devices`: **by default, if you do not pass `--devices`, it will use all GPUs on your computer**.
You can use specific GPUs by passing a list of ids (ex: `0 1 2`). To find them, you can use the following snippet:

```python
import torch
devices = [torch.cuda.device(i) for i in range(torch.cuda.device_count())]
device_names = [torch.cuda.get_device_name(d) for d in devices]
```

- `--backend`: you can specify another `backend` for `DistribuedDataParallel` if the default one is not available on
your operating system. Fastest one is `nccl` according to [PyTorch Documentation](https://pytorch.org/docs/stable/generated/torch.nn.parallel.DistributedDataParallel.html).


```shell
python references/detection/train_pytorch_ddp.py db_resnet50 --train_path path/to/your/train_set --val_path path/to/your/val_set --epochs 5 --devices 0 1 --backend nccl
```

## Data format

Expand Down
Loading

0 comments on commit c3ec3cb

Please sign in to comment.