| 1 |
# Distributed inference examples |
| 2 |
|
| 3 |
This folder contains a variety of tutorials for running distributed inference with the following strategy: |
| 4 |
|
| 5 |
Load an entire model onto each GPU and sending chunks of a batch through each GPU’s model copy at a time |
| 6 |
|
| 7 |
## Installation |
| 8 |
|
| 9 |
```bash |
| 10 |
pip install accelerate torch |
| 11 |
``` |
| 12 |
|
| 13 |
## Running code |
| 14 |
|
| 15 |
You can either use `torchrun` or the recommended way of `accelerate launch` (without needing to run `accelerate config`) on each script: |
| 16 |
|
| 17 |
```bash |
| 18 |
accelerate launch --num_processes {NUM_GPUS} phi2.py |
| 19 |
``` |
| 20 |
|
| 21 |
Or: |
| 22 |
|
| 23 |
```bash |
| 24 |
torchrun --nproc-per-node {NUM_GPUS} phi2.py |
| 25 |
``` |