Skip to content

Commit 4fdbad0

Browse files
authored
Merge pull request #5249 from luotao1/doc
correct the index of cluster_train_cn/en.md
2 parents ef2f0ec + 1a69027 commit 4fdbad0

File tree

2 files changed

+36
-36
lines changed

2 files changed

+36
-36
lines changed

doc/howto/usage/cluster/cluster_train_cn.md

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
* [启动集群作业](#启动集群作业-1)
2020
* [在Kubernetes集群中提交训练作业](#在kubernetes集群中提交训练作业)
2121

22-
# 概述
22+
## 概述
2323
本文将介绍如何使用PaddlePaddle在不同的集群框架下完成分布式训练。分布式训练架构如下图所示:
2424

2525
<img src="https://user-images.githubusercontent.com/13348433/31772175-5f419eca-b511-11e7-9db7-5231fe3d9ccb.png" width="500">
@@ -32,7 +32,7 @@
3232

3333
在使用同步SGD训练神经网络时,PaddlePaddle使用同步屏障(barrier),使梯度的提交和参数的更新按照顺序方式执行。在异步SGD中,则并不会等待所有trainer提交梯度才更新参数,这样极大地提高了计算的并行性:参数服务器之间不相互依赖,并行地接收梯度和更新参数,参数服务器也不会等待计算节点全部都提交梯度之后才开始下一步,计算节点之间也不会相互依赖,并行地执行模型的训练。可以看出,虽然异步SGD方式会提高参数更新并行度, 但是并不能保证参数同步更新,在任意时间某一台参数服务器上保存的参数可能比另一台要更新,与同步SGD相比,梯度会有噪声。
3434

35-
# 环境准备
35+
## 环境准备
3636

3737
1. 准备您的计算集群。计算集群通常由一组(几台到几千台规模)的Linux服务器组成。服务器之间可以通过局域网(LAN)联通,每台服务器具有集群中唯一的IP地址(或者可被DNS解析的主机名)。集群中的每台计算机通常被成为一个“节点”。
3838
1. 我们需要在集群的所有节点上安装 PaddlePaddle。 如果要启用GPU,还需要在节点上安装对应的GPU驱动以及CUDA。PaddlePaddle的安装可以参考[build_and_install](https://github.com/PaddlePaddle/Paddle/tree/develop/doc/getstarted/build_and_install)的多种安装方式。我们推荐使用[Docker](https://github.com/PaddlePaddle/Paddle/blob/develop/doc/getstarted/build_and_install/docker_install_cn.rst)安装方式来快速安装PaddlePaddle。
@@ -51,8 +51,8 @@ PaddlePaddle 0.10.0, compiled with
5151

5252
下面以`doc/howto/usage/cluster/src/word2vec`中的代码作为实例,介绍使用PaddlePaddle v2 API完成分布式训练。
5353

54-
# 启动参数说明
55-
## 启动参数服务器
54+
## 启动参数说明
55+
### 启动参数服务器
5656
执行以下的命令启动一个参数服务器并等待和计算节点的数据交互
5757
```bash
5858
$ paddle pserver --port=7164 --ports_num=1 --ports_num_for_sparse=1 --num_gradient_servers=1
@@ -70,7 +70,7 @@ $ stdbuf -oL /usr/bin/nohup paddle pserver --port=7164 --ports_num=1 --ports_num
7070
| ports_num_for_sparse | 必选 | 1 | 用于稀疏类型参数通信的端口个数 |
7171
| num_gradient_servers | 必选 | 1 | 当前训练任务pserver总数 |
7272

73-
## 启动计算节点
73+
### 启动计算节点
7474
执行以下命令启动使用python编写的trainer程序(文件名为任意文件名,如train.py)
7575
```bash
7676
$ python train.py
@@ -117,7 +117,7 @@ paddle.init(
117117
| pservers | 必选 | 127.0.0.1 | 当前训练任务启动的pserver的IP列表,多个IP使用“,”隔开 |
118118

119119

120-
## 准备数据集
120+
### 准备数据集
121121

122122
参考样例数据准备脚本[prepare.py](https://github.com/PaddlePaddle/Paddle/tree/develop/doc/howto/usage/cluster/src/word2vec/prepare.py),准备训练数据和验证数据集,我们使用paddle.dataset.imikolov数据集,并根据分布式训练并发数(trainer节点个数),在`prepare.py`开头部分指定`SPLIT_COUNT`将数据切分成多份。
123123

@@ -149,7 +149,7 @@ test.txt-00002
149149

150150
对于不同的训练任务,训练数据格式和训练程序的`reader()`会大不相同,所以开发者需要根据自己训练任务的实际场景完成训练数据的分割和`reader()`的编写。
151151

152-
## 准备训练程序
152+
### 准备训练程序
153153

154154
我们会对每个训练任务都会在每个节点上创建一个工作空间(workspace),其中包含了用户的训练程序、程序依赖、挂载或下载的训练数据分片。
155155

@@ -184,7 +184,7 @@ test.txt-00002
184184
- `train_data_dir`:包含训练数据的目录,可以是从分布式存储挂载过来的,也可以是在任务启动前下载到本地的。
185185
- `test_data_dir`:包含测试数据集的目录。
186186

187-
# 使用分布式计算平台或工具
187+
## 使用分布式计算平台或工具
188188

189189
PaddlePaddle可以使用多种分布式计算平台构建分布式计算任务,包括:
190190
- [Kubernetes](http://kubernetes.io) Google开源的容器集群的调度框架,支持大规模集群生产环境的完整集群方案。
@@ -195,12 +195,12 @@ PaddlePaddle可以使用多种分布式计算平台构建分布式计算任务
195195

196196
在使用分布式计算平台进行训练时,任务被调度在集群中时,分布式计算平台通常会通过API或者环境变量提供任务运行需要的参数,比如节点的ID、IP和任务节点个数等。
197197

198-
## 使用Fabric启动集群作业
198+
### 使用Fabric启动集群作业
199199

200-
### 准备一个Linux集群
200+
#### 准备一个Linux集群
201201
可以在`paddle/scripts/cluster_train_v2/fabric/docker_cluster`目录下,执行`kubectl -f ssh_servers.yaml`启动一个测试集群,并使用`kubectl get po -o wide`获得这些节点的IP地址。
202202

203-
### 启动集群作业
203+
#### 启动集群作业
204204

205205
`paddle.py` 提供了自动化脚本来启动不同节点中的所有 PaddlePaddle 集群进程。默认情况下,所有命令行选项可以设置为 `paddle.py` 命令选项并且 `paddle.py` 将透明、自动地将这些选项应用到 PaddlePaddle 底层进程。
206206

@@ -216,10 +216,10 @@ sh run.sh
216216

217217
集群作业将会在几秒后启动。
218218

219-
### 终止集群作业
219+
#### 终止集群作业
220220
`paddle.py`能获取`Ctrl + C` SIGINT 信号来自动终止它启动的所有进程。只需中断 `paddle.py` 任务来终止集群作业。如果程序崩溃你也可以手动终止。
221221

222-
### 检查集群训练结果
222+
#### 检查集群训练结果
223223
详细信息请检查 $workspace/log 里的日志,每一个节点都有相同的日志结构。
224224

225225
`paddle_trainer.INFO`
@@ -234,13 +234,13 @@ sh run.sh
234234
`train.log`
235235
提供训练过程的 stderr 和 stdout。训练失败时可以检查错误日志。
236236

237-
### 检查模型输出
237+
#### 检查模型输出
238238
运行完成后,模型文件将被写入节点 0 的 `output` 目录中。
239239
工作空间中的 `nodefile` 表示当前集群作业的节点 ID。
240240

241-
## 在OpenMPI集群中提交训练作业
241+
### 在OpenMPI集群中提交训练作业
242242

243-
### 准备OpenMPI集群
243+
#### 准备OpenMPI集群
244244

245245
执行下面的命令以启动3个节点的OpenMPI集群和一个"head"节点:
246246

@@ -252,7 +252,7 @@ kubectl create -f mpi-nodes.yaml
252252

253253
然后可以从head节点ssh无密码登录到OpenMPI的每个节点上。
254254

255-
### 启动集群作业
255+
#### 启动集群作业
256256

257257
您可以按照下面的步骤在OpenMPI集群中提交paddle训练任务:
258258

@@ -280,6 +280,6 @@ scp train.txt-00002 test.txt-00002 [node3IP]:/home/tutorial
280280
mpirun -hostfile machines -n 3 /home/tutorial/start_mpi_train.sh
281281
```
282282

283-
## 在Kubernetes集群中提交训练作业
283+
### 在Kubernetes集群中提交训练作业
284284

285285
此部分的使用方法可以参考[here](../k8s/k8s_distributed_cn.md)

doc/howto/usage/cluster/cluster_train_en.md

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
* [Launching Cluster Job](#launching-cluster-job-1)
2020
* [Cluster Training Using Kubernetes](#cluster-training-using-kubernetes)
2121

22-
# Introduction
22+
## Introduction
2323

2424
In this article, we'll explain how to run distributed training jobs with PaddlePaddle on different types of clusters. The diagram below shows the main architecture of a distributed trainning job:
2525

@@ -33,7 +33,7 @@ PaddlePaddle can support both synchronize stochastic gradient descent (SGD) and
3333

3434
When training with synchronize SGD, PaddlePaddle uses an internal "synchronize barrier" which makes gradients update and parameter download in strict order. On the other hand, asynchronous SGD won't wait for all trainers to finish upload at a single step, this will increase the parallelism of distributed training: parameter servers do not depend on each other, they'll do parameter optimization concurrently. Parameter servers will not wait for trainers, so trainers will also do their work concurrently. But asynchronous SGD will introduce more randomness and noises in the gradient.
3535

36-
# Preparations
36+
## Preparations
3737
1. Prepare your computer cluster. It's normally a bunch of Linux servers connected by LAN. Each server will be assigned a unique IP address. The computers in the cluster can be called "nodes".
3838
2. Install PaddlePaddle on every node. If you are going to take advantage of GPU cards, you'll also need to install proper driver and CUDA libraries. To install PaddlePaddle please read [this build and install](https://github.com/PaddlePaddle/Paddle/tree/develop/doc/getstarted/build_and_install) document. We strongly recommend using [Docker installation](https://github.com/PaddlePaddle/Paddle/blob/develop/doc/getstarted/build_and_install/docker_install_en.rst).
3939

@@ -52,9 +52,9 @@ PaddlePaddle 0.10.0rc, compiled with
5252

5353
We'll take `doc/howto/usage/cluster/src/word2vec` as an example to introduce distributed training using PaddlePaddle v2 API.
5454

55-
# Command-line arguments
55+
## Command-line arguments
5656

57-
## Starting parameter server
57+
### Starting parameter server
5858

5959
Type the below command to start a parameter server which will wait for trainers to connect:
6060

@@ -74,7 +74,7 @@ $ stdbuf -oL /usr/bin/nohup paddle pserver --port=7164 --ports_num=1 --ports_num
7474
| ports_num_for_sparse | required | 1 | number of ports which serves sparse parameter update |
7575
| num_gradient_servers | required | 1 | total number of gradient servers |
7676

77-
## Starting trainer
77+
### Starting trainer
7878
Type the command below to start the trainer(name the file whatever you want, like "train.py")
7979

8080
```bash
@@ -122,7 +122,7 @@ paddle.init(
122122
| trainer_id | required | 0 | ID for every trainer, start from 0 |
123123
| pservers | required | 127.0.0.1 | list of IPs of parameter servers, separated by "," |
124124

125-
## Prepare Training Dataset
125+
### Prepare Training Dataset
126126

127127
Here's some example code [prepare.py](https://github.com/PaddlePaddle/Paddle/tree/develop/doc/howto/usage/cluster/src/word2vec/prepare.py), it will download public `imikolov` dataset and split it into multiple files according to job parallelism(trainers count). Modify `SPLIT_COUNT` at the begining of `prepare.py` to change the count of output files.
128128

@@ -155,7 +155,7 @@ When job started, every trainer needs to get it's own part of data. In some dist
155155

156156
Different training jobs may have different data format and `reader()` function, developers may need to write different data prepare scripts and `reader()` functions for their job.
157157

158-
## Prepare Training program
158+
### Prepare Training program
159159

160160
We'll create a *workspace* directory on each node, storing your training program, dependencies, mounted or downloaded dataset directory.
161161

@@ -191,7 +191,7 @@ Your workspace may looks like:
191191
- `train_data_dir`: containing training data. Mount from storage service or copy trainning data to here.
192192
- `test_data_dir`: containing testing data.
193193

194-
# Use cluster platforms or cluster management tools
194+
## Use cluster platforms or cluster management tools
195195

196196
PaddlePaddle supports running jobs on several platforms including:
197197
- [Kubernetes](http://kubernetes.io) open-source system for automating deployment, scaling, and management of containerized applications from Google.
@@ -202,13 +202,13 @@ We'll introduce cluster job management on these platforms. The examples can be f
202202

203203
These cluster platforms provide API or environment variables for training processes, when the job is dispatched to different nodes. Like node ID, IP or total number of nodes etc.
204204

205-
## Cluster Training Using Fabric
205+
### Cluster Training Using Fabric
206206

207-
### Prepare a Linux cluster
207+
#### Prepare a Linux cluster
208208

209209
Run `kubectl -f ssh_servers.yaml` under the directory: `paddle/scripts/cluster_train_v2/fabric/docker_cluster` will launch a demo cluster. Run `kubectl get po -o wide` to get IP addresses of these nodes.
210210

211-
### Launching Cluster Job
211+
#### Launching Cluster Job
212212
`paddle.py` provides automatical scripts to start all PaddlePaddle cluster processes in different nodes. By default, all command line options can be set as `paddle.py` command options and `paddle.py` will transparently and automatically set these options to PaddlePaddle lower level processes.
213213

214214
`paddle.py`provides two distinguished command option for easy job launching.
@@ -224,10 +224,10 @@ sh run.sh
224224

225225
The cluster Job will start in several seconds.
226226

227-
### Kill Cluster Job
227+
#### Kill Cluster Job
228228
`paddle.py` can capture `Ctrl + C` SIGINT signal to automatically kill all processes launched by it. So just stop `paddle.py` to kill cluster job. You should manually kill the job if the program crashed.
229229

230-
### Check Cluster Training Result
230+
#### Check Cluster Training Result
231231
Check log in $workspace/log for details, each node owns same log structure.
232232

233233
`paddle_trainer.INFO`
@@ -242,13 +242,13 @@ It provides stderr and stdout of parameter server process. Check error log if tr
242242
`train.log`
243243
It provides stderr and stdout of trainer process. Check error log if training crashes.
244244

245-
### Check Model Output
245+
#### Check Model Output
246246
After one pass finished, model files will be written in `output` directory in node 0.
247247
`nodefile` in workspace indicates the node id of current cluster job.
248248

249-
## Cluster Training Using OpenMPI
249+
### Cluster Training Using OpenMPI
250250

251-
### Prepare an OpenMPI cluster
251+
#### Prepare an OpenMPI cluster
252252

253253
Run the following command to start a 3-node MPI cluster and one "head" node.
254254

@@ -260,7 +260,7 @@ kubectl create -f mpi-nodes.yaml
260260

261261
Then you can log in to every OpenMPI node using ssh without input any passwords.
262262

263-
### Launching Cluster Job
263+
#### Launching Cluster Job
264264

265265
Follow the steps to launch a PaddlePaddle training job in OpenMPI cluster:\
266266

@@ -288,6 +288,6 @@ scp train.txt-00002 test.txt-00002 [node3IP]:/home/tutorial
288288
mpirun -hostfile machines -n 3 /home/tutorial/start_mpi_train.sh
289289
```
290290

291-
## Cluster Training Using Kubernetes
291+
### Cluster Training Using Kubernetes
292292

293293
The details can be found [here](../k8s/k8s_cn.md)

0 commit comments

Comments
 (0)