From 4d95ef4aec65df72cbe378982ef128a0043313af Mon Sep 17 00:00:00 2001 From: Tanguy Pruvot Date: Fri, 17 Feb 2017 18:57:51 +0100 Subject: [PATCH] cuda: ensure the system can find the right lib if you get this error on linux, its because libcudart.so.x.x was not found ldconfig -p | grep libcudart.so.8.0 --- cuda.cpp | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/cuda.cpp b/cuda.cpp index 9b65adc..9dde388 100644 --- a/cuda.cpp +++ b/cuda.cpp @@ -27,25 +27,21 @@ extern "C" { // CUDA Devices on the System int cuda_num_devices() { - int version; + int version = 0, GPU_N = 0; cudaError_t err = cudaDriverGetVersion(&version); - if (err != cudaSuccess) - { + if (err != cudaSuccess) { applog(LOG_ERR, "Unable to query CUDA driver version! Is an nVidia driver installed?"); exit(1); } - int maj = version / 1000, min = version % 100; // same as in deviceQuery sample - if (maj < 5 || (maj == 5 && min < 5)) - { - applog(LOG_ERR, "Driver does not support CUDA %d.%d API! Update your nVidia driver!", 5, 5); + if (version < CUDART_VERSION) { + applog(LOG_ERR, "Your system does not support CUDA %d.%d API!", + CUDART_VERSION / 1000, (CUDART_VERSION % 1000) / 10); exit(1); } - int GPU_N; err = cudaGetDeviceCount(&GPU_N); - if (err != cudaSuccess) - { + if (err != cudaSuccess) { applog(LOG_ERR, "Unable to query number of CUDA devices! Is an nVidia driver installed?"); exit(1); }