diff --git a/paddle/fluid/framework/executor_gc_helper.cc b/paddle/fluid/framework/executor_gc_helper.cc index 6dc53c9649e9d54ab627825b59ab13d779c742bd..05215a9e5f14bb3ee2407b560e94bfec0b9a5c3f 100644 --- a/paddle/fluid/framework/executor_gc_helper.cc +++ b/paddle/fluid/framework/executor_gc_helper.cc @@ -156,6 +156,9 @@ void DeleteUnusedTensors(const Scope &scope, for (auto &t : *lod_tensor_arr) { garbages.emplace_back(t.MoveMemoryHolder()); } + // NOTE(wangxi): need clear the vector, otherwise lod_tensor_arr.size() is + // wrong, if size() decrease in next step, an error maybe occur. + lod_tensor_arr->clear(); } else if (var->IsType()) { } else { PADDLE_THROW(platform::errors::Unimplemented(