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

Memory optimization for fit a line demo #7321

Closed
wants to merge 7 commits into from

Conversation

QiJune
Copy link
Member

@QiJune QiJune commented Jan 8, 2018

This PR includes:

The cache memory pool can be hit:

hit cache !!!! pool index is 1, var name is fc_0.tmp_1@GRAD, cache var name is square_error_cost_0.tmp_1@GRAD, var shape is [-1L, 1L]
elementwise_add_grad
hit cache !!!! pool index is 0, var name is fc_0.b_0@GRAD, cache var name is mean_0.tmp_0@GRAD, var shape is [1L]
hit cache !!!! pool index is 0, var name is fc_0.tmp_0@GRAD, cache var name is square_error_cost_0.tmp_1, var shape is [-1L, 1L]

Memory can be saved from 102400 bytes to 90112 bytes.

Memory use before optimization in a batch

I0108 20:34:28.472046 2497127360 executor.cc:114] Memory used 36864
I0108 20:34:28.472112 2497127360 executor.cc:114] Memory used 49152
I0108 20:34:28.472159 2497127360 executor.cc:114] Memory used 53248
I0108 20:34:28.472302 2497127360 executor.cc:114] Memory used 57344
I0108 20:34:28.472363 2497127360 executor.cc:114] Memory used 61440
I0108 20:34:28.472487 2497127360 executor.cc:114] Memory used 65536
I0108 20:34:28.472534 2497127360 executor.cc:114] Memory used 69632
I0108 20:34:28.472662 2497127360 executor.cc:114] Memory used 73728
I0108 20:34:28.472720 2497127360 executor.cc:114] Memory used 77824
I0108 20:34:28.472798 2497127360 executor.cc:114] Memory used 81920
I0108 20:34:28.472895 2497127360 executor.cc:114] Memory used 86016
I0108 20:34:28.472966 2497127360 executor.cc:114] Memory used 90112
I0108 20:34:28.473053 2497127360 executor.cc:114] Memory used 98304
I0108 20:34:28.473188 2497127360 executor.cc:114] Memory used 102400
I0108 20:34:28.473237 2497127360 executor.cc:114] Memory used 102400
I0108 20:34:28.473333 2497127360 executor.cc:114] Memory used 102400
I0108 20:34:28.473363 2497127360 executor.cc:126] Memory used 102400
I0108 20:34:28.473496 2497127360 executor.cc:130] Memory used after deleting local scope 36864

Memory use after optimization in a batch

I0108 20:35:11.611282 2497127360 executor.cc:114] Memory used 36864
I0108 20:35:11.611460 2497127360 executor.cc:114] Memory used 49152
I0108 20:35:11.611562 2497127360 executor.cc:114] Memory used 53248
I0108 20:35:11.611773 2497127360 executor.cc:114] Memory used 57344
I0108 20:35:11.612010 2497127360 executor.cc:114] Memory used 61440
I0108 20:35:11.612197 2497127360 executor.cc:114] Memory used 65536
I0108 20:35:11.612269 2497127360 executor.cc:114] Memory used 69632
I0108 20:35:11.612385 2497127360 executor.cc:114] Memory used 73728
I0108 20:35:11.612460 2497127360 executor.cc:114] Memory used 77824
I0108 20:35:11.612624 2497127360 executor.cc:114] Memory used 81920
I0108 20:35:11.612782 2497127360 executor.cc:114] Memory used 86016
I0108 20:35:11.612910 2497127360 executor.cc:114] Memory used 86016
I0108 20:35:11.613070 2497127360 executor.cc:114] Memory used 86016
I0108 20:35:11.613468 2497127360 executor.cc:114] Memory used 90112
I0108 20:35:11.613684 2497127360 executor.cc:114] Memory used 90112
I0108 20:35:11.613921 2497127360 executor.cc:114] Memory used 90112
I0108 20:35:11.614055 2497127360 executor.cc:126] Memory used 90112
I0108 20:35:11.614233 2497127360 executor.cc:130] Memory used after deleting local scope 36864

# print(block_size)

# TODO(qijun) handle Program with if/while operators
self.global_block = program_desc.block(0)
Copy link
Collaborator

Choose a reason for hiding this comment

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

We can just handle memory optimization for each block and do not optimize the memory between block. It may be enough.

@@ -116,6 +115,7 @@ void Executor::Run(const ProgramDesc& pdesc, Scope* scope, int block_id,
for (auto& op_desc : block.AllOps()) {
auto op = paddle::framework::OpRegistry::CreateOp(*op_desc);
VLOG(3) << op->DebugStringEx(local_scope);
VLOG(3) << "Memory used " << memory::memory_usage(place_);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Do we need a little more details in this log message, e.g., “before ....” or “after ...”?

Copy link
Member Author

Choose a reason for hiding this comment

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

This PR mainly provides a demo to show the result and these logs are actually for debugging. And another clean PR focus on memory optimization transpiler #7356 has been merged.
So I will close this PR.

@QiJune QiJune closed this Jan 10, 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.

3 participants