From 97e76cb96d6af057fa5c13f4555a89726fe52400 Mon Sep 17 00:00:00 2001 From: Zeng Jinle <32832641+sneaxiy@users.noreply.github.com> Date: Fri, 6 Dec 2019 04:18:25 -0600 Subject: [PATCH] refine dev_ctx.Wait() exception throw, test=develop (#21600) --- paddle/fluid/platform/device_context.cc | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/paddle/fluid/platform/device_context.cc b/paddle/fluid/platform/device_context.cc index d50d494a93a..54abd967f48 100644 --- a/paddle/fluid/platform/device_context.cc +++ b/paddle/fluid/platform/device_context.cc @@ -324,16 +324,10 @@ void CUDADeviceContext::Wait() const { } #endif - if (cudaSuccess != e_sync) { - LOG(FATAL) << "cudaStreamSynchronize " << cudaGetErrorString(e_sync) - << " errno: " << e_sync; - } - - cudaError_t e_get = cudaGetLastError(); - if (cudaSuccess != e_get) { - LOG(FATAL) << "cudaGetLastError " << cudaGetErrorString(e_get) - << " errno: " << e_get; - } + PADDLE_ENFORCE_CUDA_SUCCESS( + e_sync, platform::errors::Fatal( + "cudaStreamSynchronize raises error: %s, errono: %d", + cudaGetErrorString(e_sync), static_cast(e_sync))); } int CUDADeviceContext::GetComputeCapability() const { -- GitLab