From 759530966c8eca351c251bcc881e10b03d4f08e5 Mon Sep 17 00:00:00 2001 From: liuwei1031 <46661762+liuwei1031@users.noreply.github.com> Date: Tue, 16 Jul 2019 11:34:12 +0800 Subject: [PATCH] print out error code of cudaGetDeviceProperties if failed (#18643) --- paddle/fluid/platform/gpu_info.cc | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/paddle/fluid/platform/gpu_info.cc b/paddle/fluid/platform/gpu_info.cc index a8f3b084b0..b12647e0f2 100644 --- a/paddle/fluid/platform/gpu_info.cc +++ b/paddle/fluid/platform/gpu_info.cc @@ -106,9 +106,11 @@ int GetCUDADeviceCount() { int GetCUDAComputeCapability(int id) { PADDLE_ENFORCE_LT(id, GetCUDADeviceCount(), "id must less than GPU count"); cudaDeviceProp device_prop; - PADDLE_ENFORCE(cudaGetDeviceProperties(&device_prop, id), + auto error_code = cudaGetDeviceProperties(&device_prop, id); + PADDLE_ENFORCE(error_code, "cudaGetDeviceProperties failed in " - "paddle::platform::GetCUDAComputeCapability"); + "paddle::platform::GetCUDAComputeCapability, error code : %d", + error_code); return device_prop.major * 10 + device_prop.minor; } -- GitLab