-
Notifications
You must be signed in to change notification settings - Fork 5.9k
Design doc: submit a distributed job #1770
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
Changes from 23 commits
3331bda
7faa331
718f901
fd9e1c2
c095a93
d74d9ba
f4c7bd2
bb7263f
005c3e1
0f113d3
b6969f9
1771707
a21743a
d643295
5827dc1
02d18b2
68ff895
1fd8900
a57bb04
1987b45
6f097a3
bfdd1a3
b56e7e7
b8e63d9
6cbf80d
cb39a81
063805d
e2e6875
5ec1deb
53b5afa
198d0d1
838509b
259731a
a5a0aeb
080e633
05d6e00
8486227
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,111 @@ | ||
| # Submit a Distributed Training Job | ||
|
|
||
| If a user wants to start up a distributed training job, he will submit the distributed training job with Python code. | ||
|
|
||
| If a user wants to start up a local train, he will start up a PaddlePaddle production Docker container firstly, and then | ||
| execute `python train.py` in the Docker container. The details about PaddlePaddle Docker image is [here](../../../paddle/scripts/docker/README.md). | ||
|
|
||
| ## Runtime Environment On Kubernetes | ||
|
|
||
| For a distributed training job, there is two Docker image called *runtime Docker image* and *base Docker image*. The runtime Docker image is the Docker image that gets scheduled by Kubernetes to run during training. The base Docker image is for building the runtime Docker image. | ||
|
|
||
| - Base Docker Image | ||
|
|
||
| Usually, the base Docker image is PaddlePaddle product Docker image including paddle binary files and trainer startup script file. And of course, users can specify any image name hosted on any docker registry which users have the access right. | ||
|
|
||
| - Runtime Docker Image | ||
|
|
||
| The trainer package which user upload and some Python dependencies are packaged into a runtime Docker image based on base Docker image | ||
|
||
|
|
||
| - Python Dependencies | ||
|
||
|
|
||
| You need to provide requirments.txt file in your "trainer" package. Example: | ||
|
||
| ```txt | ||
| pillow | ||
| protobuf==3.1.0 | ||
| ``` | ||
| More [details](https://pip.readthedocs.io/en/1.1/requirements.html) about requirements. | ||
|
|
||
| An example project looks like: | ||
| ```bash | ||
| paddle_example | ||
| |-quick_start | ||
| |-trainer.py | ||
| |-dataset.py | ||
| |-requirments.txt | ||
|
||
| ``` | ||
|
|
||
| ## Submit Distributed Training Job With Python Code | ||
| <img src="./src/submit-job-python.png" width="800"> | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Need a paragraph to describe the flow in a big picture. The paragraph below goes directly to the detail of
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Docker build / Docker push应该是箭头那根线上的东西吧,这些都是动作,感觉应该放在线上,而不是图上(这里的图基本都是名词/一个概念)
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done. |
||
|
|
||
| You can call `paddle.dist_train` and provide distributed training configuration as the parameters. | ||
| ```python | ||
| paddle.dist_train( | ||
| trainer=paddle.trainer.SGD(..., | ||
| paddle.updater.Adam(...)), | ||
| reader=reader, | ||
| paddle_job=PaddleJob( | ||
| job_name="quickstart", | ||
| pservers=4, | ||
|
||
| volume="quickstart", | ||
| input=/quickstart/input, | ||
|
||
| output=/quickstart/output, | ||
| base_image="paddlepaddle/paddle:0.10.rc2", | ||
| use_gpu=False, | ||
| memory="512M") | ||
| ) | ||
| ``` | ||
|
|
||
| The pseudo code of `paddle.dist_train` is as follows: | ||
| ```python | ||
| def dist_train(trainer, reader, num_passes=1, event_handler=None, feeding=None, paddle_job=None): | ||
| if os.getenv("PADDLE_NOTEBOOK", "NO") == "YES": | ||
| #submit the paddle job | ||
| paddle_job.submit() | ||
| else: | ||
| #start the training | ||
| trainer.train(reader, num_passes, event_handler, feeding) | ||
| ``` | ||
|
|
||
| parameter | required | default | explain | ||
|
||
| --- | --- | --- | --- | ||
| job_name|YES||you should special a uniq job name which in a namespace | ||
| trainer_package|YES|| entry point for startup trainer process | ||
|
||
| input| YES || input directory on distributed file system | ||
| output|YES|| output directory on distributed file system | ||
| pservers|YES|| parameter server process count | ||
|
||
| base-image|YES||PaddlePaddle production Docker image | ||
| memory|YES|| limits for memory | ||
| use_gpu|NO|false| whether use GPU | ||
| cpu_num|NO|1| if `use_gpu=false`, this parameter is required | ||
| gpu_num|NO|1| if `use_gpu=true`, this parameter is required | ||
|
|
||
| - Startup Parameter Server and Trainer Jobs | ||
| - Deploy parameter server job, it's a Kubernetes ReplicaSet. | ||
| - Deploy trainer job, it's a Kubernetes Job. | ||
|
|
||
| # Job Server | ||
|
|
||
| - RESTful API | ||
|
|
||
| Job server provides a RESTful HTTP server receives the trainer packages, list PaddlePaddle job etc... | ||
|
||
| - `POST /v1/package` receive the trainer package and save them on CephFS | ||
| - `POST /v1/trainer/job` submit a trainer job | ||
| - `GET /v1/jobs/` list all jobs | ||
| - `GET /v1/jobs/<job-name>` the status of a job | ||
| - `DELETE /v1/jobs/<job-name>` delete a job | ||
| - `GET /v1/version` job server version | ||
|
|
||
| - Build Runtime Docker Image on Kubernetes | ||
|
|
||
| `paddle.dist_train` will upload the trainer package to Job Server and then save them on the distributed filesystem, and then start up a job for building the runtime Docker image, Parameter Server and Trainer will use this runtime Docker image. | ||
|
|
||
| There are some benefits for building runtime Docker image on JobServer: | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 我们最后觉得是在JobServer上build image还是在本地build image?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 这一期因为所有代码都是在云端存储上,所以就不build image了直接copy trainer_package比较简单。根据之前的讨论后续还是在JobServer上来build runtime Docker image感觉比较合适。
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done. |
||
| - **Docker in Docker** should mount `docker.sock` in the container and set `--privileged`, if the code running in a kubernetes pod, it's not safe. | ||
|
||
| - Users only need to upload the training package files, does not dependency docker engine, docker registry. | ||
|
||
| - If we want to change another image type, such as RKT, the user does not need to care about it. | ||
|
|
||
| - Start Up Parameter Server and Trainer Jobs | ||
| `POST /v1/trainer/job` receives the distributed trainning parameters, and deploy the job as follows: | ||
| - Deploy pserver job, it's a Kubernetes ReplicaSet. | ||
| - Deploy trainer job, it's a Kubernetes Job. | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
文章题目是"Submit a Distributed Training Job",是不是本地训练就不用说了(或者不用详细说,这里本地训练的介绍字数比远程训练的介绍字数还多)。
是不是可以改成:
The user can submit a distributed training job with Python code, rather than with a command-line interface.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.