diff --git a/paddle/fluid/platform/gpu_info.cc b/paddle/fluid/platform/gpu_info.cc index 8191d688472a3eb0f297936f3387e77809a20e2f..add5cabd444bfe1cff259c1626835dbad2c8b63c 100644 --- a/paddle/fluid/platform/gpu_info.cc +++ b/paddle/fluid/platform/gpu_info.cc @@ -39,6 +39,14 @@ inline std::string CudaErrorWebsite() { } static int GetCUDADeviceCountImpl() { + int driverVersion = 0; + cudaError_t status = cudaDriverGetVersion(&driverVersion); + + if (!(status == cudaSuccess && driverVersion != 0)) { + // No GPU driver + return 0; + } + const auto *cuda_visible_devices = std::getenv("CUDA_VISIBLE_DEVICES"); if (cuda_visible_devices != nullptr) { std::string cuda_visible_devices_str(cuda_visible_devices);