diff --git a/paddle/fluid/platform/device_context.cc b/paddle/fluid/platform/device_context.cc index d50d494a93a8a98547a0d753daec4b194f0dcef0..54abd967f48d9e58c01420e0c5dc3b5072854fac 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 {