Skip to content

Conversation

@QiJune
Copy link
Member

@QiJune QiJune commented Feb 1, 2018

Have tested in machine translation demo.

In the first batch training, memory reduced from 5728446208 to 1115982080, saves 80.5% memory.

It seems that delete_var operator has no contribution for the result. I will remove it.

dzhwinter
dzhwinter previously approved these changes Feb 1, 2018
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.

My point is same with you. This PR will save a huge memory for while_grad, so we will merge it early.
Please fix the issues later.

cur_scope.Rename(new_inside_name, inside_grad_name);
}
dev_ctx.Wait();
const_cast<framework::Scope &>(scope).DeleteScope(&cur_scope);
Copy link
Contributor

Choose a reason for hiding this comment

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

Nice catch!
This fix will solve the headache OOM.

/// Drop all kids scopes belonged to this scope.
void DropKids();

void EraseVars(std::vector<std::string>& var_names);
Copy link
Contributor

Choose a reason for hiding this comment

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

Since our every variable will be released after we destruct the scope, In my humble view, this interface should never be used.

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.

LGTM!

sum_op->Run(cur_scope, dev_place);
cur_scope.Rename(new_inside_name, inside_grad_name);
}
dev_ctx.Wait();

Choose a reason for hiding this comment

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

what is the cost of adding this dev_ctx.Wait();?

Copy link
Member Author

Choose a reason for hiding this comment

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

I have not make detailed test yet. But if we do not delete the step scope, we can not training a larger RNN model because of OutOfMemory.

@QiJune QiJune merged commit c1ac5b6 into PaddlePaddle:develop Feb 2, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

3 participants