From 751812a674c8933c6a6c6f22b16693ec18985331 Mon Sep 17 00:00:00 2001 From: Wilber Date: Sat, 12 Oct 2019 09:39:18 +0800 Subject: [PATCH] enable cpu machine to run paddle in gpu lib enable cpu machine to run paddle model in gpu lib --- paddle/fluid/platform/gpu_info.cc | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/paddle/fluid/platform/gpu_info.cc b/paddle/fluid/platform/gpu_info.cc index 8191d688472..add5cabd444 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); -- GitLab