diff --git a/paddle/fluid/framework/details/fast_threaded_ssa_graph_executor.cc b/paddle/fluid/framework/details/fast_threaded_ssa_graph_executor.cc index 227a366f22fbbfebf68b53d321cf8daff3300662..7606f2bc06b2ecf07c5649eeae1a2d5587a8880c 100644 --- a/paddle/fluid/framework/details/fast_threaded_ssa_graph_executor.cc +++ b/paddle/fluid/framework/details/fast_threaded_ssa_graph_executor.cc @@ -101,9 +101,15 @@ FeedFetchList FastThreadedSSAGraphExecutor::Run( while (num_complete != op_deps->size()) { size_t num_comp = complete_q.Pop(); if (num_comp == -1UL) { - int remaining = remaining_; - for (int i = 0; i < remaining; ++i) { - complete_q.Pop(); + int remaining = 0; + while (true) { + remaining = remaining_; + if (remaining == 0) { + break; + } + for (int i = 0; i < remaining; ++i) { + complete_q.Pop(); + } } exception_.ReThrow(); }