Skip to content

Commit

Permalink
fix mem release error.
Browse files Browse the repository at this point in the history
  • Loading branch information
jiweibo committed Apr 28, 2021
1 parent 33703da commit a2d0e76
Showing 1 changed file with 2 additions and 16 deletions.
18 changes: 2 additions & 16 deletions paddle/fluid/inference/api/analysis_predictor.cc
Original file line number Diff line number Diff line change
Expand Up @@ -191,22 +191,8 @@ bool AnalysisPredictor::PrepareScope(
status_is_cloned_ = true;
} else {
paddle::framework::InitDevices();
scope_.reset(new paddle::framework::Scope(), [](framework::Scope *scope) {
delete scope;
#if defined(PADDLE_WITH_CUDA) || defined(PADDLE_WITH_HIP)
for (int dev_id = 0; dev_id < paddle::platform::GetCUDADeviceCount();
++dev_id) {
memory::Release(platform::CUDAPlace(dev_id));
}
#endif
#ifdef PADDLE_WITH_XPU
for (int dev_id = 0; dev_id < paddle::platform::GetXPUDeviceCount();
++dev_id) {
memory::Release(platform::XPUPlace(dev_id));
}
#endif
memory::Release(platform::CPUPlace());
});
// TODO(wilber): we need to release memory occupied by weights.
scope_.reset(new paddle::framework::Scope());
status_is_cloned_ = false;
}
sub_scope_ = &scope_->NewScope();
Expand Down

1 comment on commit a2d0e76

@paddle-bot-old
Copy link

Choose a reason for hiding this comment

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

Congratulation! Your pull request passed all required CI. You could ask reviewer(s) to approve and merge. 🎉

Please sign in to comment.