Skip to content
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

Benchmark/Integrate benchmark scripts #10707

Merged

Conversation

typhoonzero
Copy link
Contributor

@typhoonzero typhoonzero commented May 16, 2018

Integrate all benchmark python programs to one, we can then run a command like:

python fluid_benchmark.py --model vgg --parallel 1 --device GPU  --data_set flowers --memory_optimize --with_test

to start either local CPU/GPU benchmarking or distributed multi-GPU benchmarking.

In distributed mode, corresponding environment variables must be set to let workers know which role is that node.

@typhoonzero typhoonzero changed the title [WIP] Benchmark/Integrate benchmark scripts Benchmark/Integrate benchmark scripts May 17, 2018
default=0.001,
help='The minibatch size.')
# TODO(wuyi): add this option back.
# parser.add_argument(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove these

def append_nccl2_prepare():
if os.getenv("PADDLE_TRAINER_ID", None) != None:
# append gen_nccl_id at the end of startup program
trainer_id = int(os.getenv("PADDLE_TRAINER_ID"))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what if the env not exists

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the user added --update_method nccl2 and didn't provide PADDLE_TRAINER_ID, this script will raise an error, else if the user didn't provide --update_method it will run default as local training.

@@ -0,0 +1,60 @@
# Fluid Benchmark

This directory contains several models and tools that used to run
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

several models => several model configurations.

exit(0)
return loss, inference_program, adam, train_reader, test_reader, batch_acc

# iters, num_samples, start_time = 0, 0, time.time()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please delete these unused code.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

'--with_test',
action='store_true',
help='If set, test the testset during training.')
parser.add_argument(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe this should be added by default?

if args.parallel == 0:
# NOTE: parallel executor use profiler interanlly
if args.use_nvprof and args.device == 'GPU':
with profiler.cuda_profiler("cuda_profiler.txt", 'csv') as nvprof:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

actually, the cuda_profiler is not used anymore, I will fire a PR and delete them.

raise Exception(
"Must configure correct environments to run dist train.")
train_args.extend([train_prog, startup_prog])
if args.parallel == 1 and os.getenv(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

parallel == 1 will lead to the confused meaning of thread count, how about change to another name?

# to let container set rlimit
"securityContext": {
"privileged": True
# "capabilities": {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

commented out code

import random
import os

pserver = {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The distributed jobs have a lot of same configurations, but now these templates and environment variables messed up inside the job generative script. We can put a template yaml configuration file, and set the variable default value with arguments in submit scripts.

import os

pserver = {
"apiVersion": "extensions/v1beta1",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And, In my view, the yaml format is more concise than json format? which one do you prefer?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comments all done, I kept using json so that we can directly import it as in-memory data.

Copy link
Contributor

@dzhwinter dzhwinter left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great Job. We can launch the dist benchmark scripts on CE now.

batch_acc)
print(", Test Accuracy: %f" % pass_test_acc)
print("\n")
# TODO(wuyi): add warmup passes to get better perf data.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the skip_batch_num arguments do the trick. In my experiment, in the local machine 5-10 batches would be fine.

@typhoonzero typhoonzero merged commit 55d3951 into PaddlePaddle:develop May 23, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants