From b0b0d62820ad53d29b8f68787028194266b86c5b Mon Sep 17 00:00:00 2001 From: Wilber Date: Sun, 13 Oct 2019 13:55:03 +0800 Subject: [PATCH] fix cpu machine run paddle in gpu lib test=release/1.6 (#20548) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit cpu机器在gpu库上运行paddle出core,原因是由于缺失显卡driver,显卡driver与cuda driver不匹配 加上driver check解决该问题 --- 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