From 76570c2e969df26fff28f22e1d6e8fe18cf5e45c Mon Sep 17 00:00:00 2001 From: Yu Yang Date: Tue, 27 Mar 2018 13:56:14 +0800 Subject: [PATCH] Wait fetch op --- paddle/fluid/framework/details/fetch_op_handle.cc | 1 + paddle/fluid/framework/details/op_handle_base.cc | 3 --- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/paddle/fluid/framework/details/fetch_op_handle.cc b/paddle/fluid/framework/details/fetch_op_handle.cc index 03323e3da7..26c09eb8eb 100644 --- a/paddle/fluid/framework/details/fetch_op_handle.cc +++ b/paddle/fluid/framework/details/fetch_op_handle.cc @@ -66,6 +66,7 @@ void FetchOpHandle::RunImpl() { if (platform::is_gpu_place(var->place_)) { #ifdef PADDLE_WITH_CUDA TensorCopy(t, cpu, *dev_ctx_[t.place()], &tensors_[i]); + dev_ctx_[t.place()]->Wait(); #endif } else { tensors_[i].ShareDataWith(t); diff --git a/paddle/fluid/framework/details/op_handle_base.cc b/paddle/fluid/framework/details/op_handle_base.cc index 07a4b89217..63affb7054 100644 --- a/paddle/fluid/framework/details/op_handle_base.cc +++ b/paddle/fluid/framework/details/op_handle_base.cc @@ -33,9 +33,6 @@ std::string OpHandleBase::DebugString() const { OpHandleBase::~OpHandleBase() { #ifdef PADDLE_WITH_CUDA - for (auto &ctx : dev_ctx_) { - ctx.second->Wait(); - } for (auto &ev : events_) { PADDLE_ENFORCE(cudaEventDestroy(ev.second)); } -- GitLab