Skip to content

Commit 173d72b

Browse files
committed
Merge branch 'develop' of https://github.com/PaddlePaddle/Paddle into enable_cpu_on_pe
2 parents aadaadf + b3fd9da commit 173d72b

File tree

119 files changed

+3814
-1498
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

119 files changed

+3814
-1498
lines changed

benchmark/fluid/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,4 @@ ADD *.whl /
1919
RUN pip install /*.whl && rm -f /*.whl && chmod +x /usr/bin/paddle_k8s
2020

2121
ENV LD_LIBRARY_PATH=/usr/local/lib
22-
ADD fluid_benchmark.py dataset.py models/ /workspace/
22+
ADD fluid_benchmark.py recordio_converter.py models/ /workspace/

benchmark/fluid/README.md

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,12 @@ Currently supported `--model` argument include:
2424

2525
* Run the following command to start a benchmark job locally:
2626
```bash
27-
python fluid_benchmark.py --model mnist --device GPU
27+
python fluid_benchmark.py --model mnist --device GPU
2828
```
2929
You can choose to use GPU/CPU training. With GPU training, you can specify
3030
`--gpus <gpu_num>` to run multi GPU training.
31+
You can set async mode parameter server. With async mode, you can specify
32+
`--async_mode` to train model asynchronous.
3133
* Run distributed training with parameter servers:
3234
* see [run_fluid_benchmark.sh](https://github.com/PaddlePaddle/Paddle/blob/develop/benchmark/fluid/run_fluid_benchmark.sh) as an example.
3335
* start parameter servers:
@@ -44,6 +46,16 @@ Currently supported `--model` argument include:
4446
PADDLE_PSERVER_PORT=7164 PADDLE_TRAINER_IPS=192.168.0.2,192.168.0.3 PADDLE_CURRENT_IP=127.0.0.1 PADDLE_TRAINER_ID=0 python fluid_benchmark.py --model mnist --device GPU --update_method nccl2
4547
```
4648

49+
## Prepare the RecordIO file to Achieve Better Performance
50+
51+
Run the following command will generate RecordIO files like "mnist.recordio" under the path
52+
and batch_size you choose, you can use batch_size=1 so that later reader can change the batch_size
53+
at any time using `fluid.batch`.
54+
55+
```bash
56+
python -c 'from recordio_converter import *; prepare_mnist("data", 1)'
57+
```
58+
4759
## Run Distributed Benchmark on Kubernetes Cluster
4860

4961
You may need to build a Docker image before submitting a cluster job onto Kubernetes, or you will

benchmark/fluid/args.py

Lines changed: 126 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,126 @@
1+
# Copyright (c) 2018 PaddlePaddle Authors. All Rights Reserved.
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
import argparse
16+
17+
__all__ = ['parse_args', ]
18+
19+
BENCHMARK_MODELS = [
20+
"machine_translation", "resnet", "vgg", "mnist", "stacked_dynamic_lstm"
21+
]
22+
23+
24+
def parse_args():
25+
parser = argparse.ArgumentParser('Fluid model benchmarks.')
26+
parser.add_argument(
27+
'--model',
28+
type=str,
29+
choices=BENCHMARK_MODELS,
30+
default='resnet',
31+
help='The model to run benchmark with.')
32+
parser.add_argument(
33+
'--batch_size', type=int, default=32, help='The minibatch size.')
34+
# args related to learning rate
35+
parser.add_argument(
36+
'--learning_rate', type=float, default=0.001, help='The learning rate.')
37+
# TODO(wuyi): add "--use_fake_data" option back.
38+
parser.add_argument(
39+
'--skip_batch_num',
40+
type=int,
41+
default=5,
42+
help='The first num of minibatch num to skip, for better performance test'
43+
)
44+
parser.add_argument(
45+
'--iterations', type=int, default=80, help='The number of minibatches.')
46+
parser.add_argument(
47+
'--pass_num', type=int, default=100, help='The number of passes.')
48+
parser.add_argument(
49+
'--data_format',
50+
type=str,
51+
default='NCHW',
52+
choices=['NCHW', 'NHWC'],
53+
help='The data data_format, now only support NCHW.')
54+
parser.add_argument(
55+
'--device',
56+
type=str,
57+
default='GPU',
58+
choices=['CPU', 'GPU'],
59+
help='The device type.')
60+
parser.add_argument(
61+
'--gpus',
62+
type=int,
63+
default=1,
64+
help='If gpus > 1, will use ParallelExecutor to run, else use Executor.')
65+
# this option is available only for vgg and resnet.
66+
parser.add_argument(
67+
'--cpus',
68+
type=int,
69+
default=1,
70+
help='If cpus > 1, will use ParallelDo to run, else use Executor.')
71+
parser.add_argument(
72+
'--data_set',
73+
type=str,
74+
default='flowers',
75+
choices=['cifar10', 'flowers'],
76+
help='Optional dataset for benchmark.')
77+
parser.add_argument(
78+
'--infer_only', action='store_true', help='If set, run forward only.')
79+
parser.add_argument(
80+
'--use_cprof', action='store_true', help='If set, use cProfile.')
81+
parser.add_argument(
82+
'--use_nvprof',
83+
action='store_true',
84+
help='If set, use nvprof for CUDA.')
85+
parser.add_argument(
86+
'--no_test',
87+
action='store_true',
88+
help='If set, do not test the testset during training.')
89+
parser.add_argument(
90+
'--memory_optimize',
91+
action='store_true',
92+
help='If set, optimize runtime memory before start.')
93+
parser.add_argument(
94+
'--use_fake_data',
95+
action='store_true',
96+
help='If set ommit the actual read data operators.')
97+
parser.add_argument(
98+
'--profile', action='store_true', help='If set, profile a few steps.')
99+
parser.add_argument(
100+
'--update_method',
101+
type=str,
102+
default='local',
103+
choices=['local', 'pserver', 'nccl2'],
104+
help='Choose parameter update method, can be local, pserver, nccl2.')
105+
parser.add_argument(
106+
'--no_split_var',
107+
action='store_true',
108+
default=False,
109+
help='Whether split variables into blocks when update_method is pserver')
110+
parser.add_argument(
111+
'--async_mode',
112+
action='store_true',
113+
default=False,
114+
help='Whether start pserver in async mode to support ASGD')
115+
parser.add_argument(
116+
'--use_reader_op',
117+
action='store_true',
118+
help='Whether to use reader op, and must specify the data path if set this to true.'
119+
)
120+
parser.add_argument(
121+
'--data_path',
122+
type=str,
123+
default="",
124+
help='Directory that contains all the training recordio files.')
125+
args = parser.parse_args()
126+
return args

0 commit comments

Comments
 (0)