Auto_Parallel.md 1.96 KB
Newer Older
yuguo960516's avatar
glm  
yuguo960516 committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
# Auto Parallel Training

LiBai supports **auto-parallel training** which means LiBai will automatically find **an efficient parallel training strategy** for a specific model during training. Users can try out auto-parallel training by the following steps.

## Installation

Install OneFlow nightly

```shell
python3 -m pip install --pre oneflow -f https://staging.oneflow.info/branch/master/[PLATFORM]
```

- All available `[PLATFORM]`:

<table class="docutils">
  <tbody>
    <tr>
      <th width="80"> Platform </th>
      <th valign="bottom" align="left" width="120">CUDA Driver Version</th>
      <th valign="bottom" align="left" width="120">Supported GPUs</th>
    </tr>
    <tr>
      <td align="left"> cu112 </td>
      <td align="left"> >= 450.80.02 </td>
      <td align="left"> GTX 10xx, RTX 20xx, A100, RTX 30xx</td>
    </tr>
    <tr>
      <td align="left"> cu102 </td>
      <td align="left"> >= 440.33 </td>
      <td align="left"> GTX 10xx, RTX 20xx</td>
    </tr>
    <tr>
      <td align="left"> cpu </td>
      <td align="left"> N/A </td>
      <td align="left"> N/A </td>
    </tr>
  </tbody>
</table>


## Train/Evaluate model in auto-parallel mode

You can train your own model in auto-parallel mode by simply updating the config as follows:

### Modify config file

```python
# your config
from .common.models.graph import graph

graph.auto_parallel.enabled = True
```
Training model with auto-parallel on 4 GPUs:
```shell
bash ./tools/train.sh tools/train_net.py configs/your_own_config.py 4
```

### Directly modify the training command line

- auto-parallel training:

```shell
bash ./tools/train.sh tools/train_net.py configs/your_own_config.py 4 graph.auto_parallel.enabled=True
```

- auto-parallel evaluation:

```shell
bash ./tools/train.sh tools/train_net.py configs/your_own_config.py 4 --eval graph.auto_parallel.enabled=True
```

### More details with instructions and interface

See [OneFlow Auto-Parallelism](https://oneflow.readthedocs.io/en/master/auto_parallel.html).