From 45073b7c3971771ab14d82baec09ca13b2fe3953 Mon Sep 17 00:00:00 2001 From: qingqing01 Date: Thu, 15 Mar 2018 16:57:14 +0800 Subject: [PATCH] Always synchronize when copy data on GPU from C++ to Numpy array. (#9110) --- paddle/fluid/pybind/tensor_py.h | 1 + 1 file changed, 1 insertion(+) diff --git a/paddle/fluid/pybind/tensor_py.h b/paddle/fluid/pybind/tensor_py.h index 3b206f2f87a..6f8c597f8e6 100644 --- a/paddle/fluid/pybind/tensor_py.h +++ b/paddle/fluid/pybind/tensor_py.h @@ -72,6 +72,7 @@ struct CastToPyBufferImpl { paddle::platform::GpuMemcpyAsync( dst_ptr, src_ptr, sizeof(CUR_TYPE) * tensor.numel(), cudaMemcpyDeviceToHost, dev_ctx->stream()); + dev_ctx->Wait(); #else PADDLE_THROW("'CUDAPlace' is not supported in CPU only device."); #endif -- GitLab