Browse Source

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
2upstream
Tanguy Pruvot 8 years ago
parent
commit
4d95ef4aec
  1. 16
      cuda.cpp

16
cuda.cpp

@ -27,25 +27,21 @@ extern "C" {
// CUDA Devices on the System // CUDA Devices on the System
int cuda_num_devices() int cuda_num_devices()
{ {
int version; int version = 0, GPU_N = 0;
cudaError_t err = cudaDriverGetVersion(&version); 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?"); applog(LOG_ERR, "Unable to query CUDA driver version! Is an nVidia driver installed?");
exit(1); exit(1);
} }
int maj = version / 1000, min = version % 100; // same as in deviceQuery sample if (version < CUDART_VERSION) {
if (maj < 5 || (maj == 5 && min < 5)) applog(LOG_ERR, "Your system does not support CUDA %d.%d API!",
{ CUDART_VERSION / 1000, (CUDART_VERSION % 1000) / 10);
applog(LOG_ERR, "Driver does not support CUDA %d.%d API! Update your nVidia driver!", 5, 5);
exit(1); exit(1);
} }
int GPU_N;
err = cudaGetDeviceCount(&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?"); applog(LOG_ERR, "Unable to query number of CUDA devices! Is an nVidia driver installed?");
exit(1); exit(1);
} }

Loading…
Cancel
Save