Skip to content

Commit 4d95ef4

Browse files
committed
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
1 parent 1d5db48 commit 4d95ef4

File tree

1 file changed

+6
-10
lines changed

1 file changed

+6
-10
lines changed

cuda.cpp

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -27,25 +27,21 @@ extern "C" {
2727
// CUDA Devices on the System
2828
int cuda_num_devices()
2929
{
30-
int version;
30+
int version = 0, GPU_N = 0;
3131
cudaError_t err = cudaDriverGetVersion(&version);
32-
if (err != cudaSuccess)
33-
{
32+
if (err != cudaSuccess) {
3433
applog(LOG_ERR, "Unable to query CUDA driver version! Is an nVidia driver installed?");
3534
exit(1);
3635
}
3736

38-
int maj = version / 1000, min = version % 100; // same as in deviceQuery sample
39-
if (maj < 5 || (maj == 5 && min < 5))
40-
{
41-
applog(LOG_ERR, "Driver does not support CUDA %d.%d API! Update your nVidia driver!", 5, 5);
37+
if (version < CUDART_VERSION) {
38+
applog(LOG_ERR, "Your system does not support CUDA %d.%d API!",
39+
CUDART_VERSION / 1000, (CUDART_VERSION % 1000) / 10);
4240
exit(1);
4341
}
4442

45-
int GPU_N;
4643
err = cudaGetDeviceCount(&GPU_N);
47-
if (err != cudaSuccess)
48-
{
44+
if (err != cudaSuccess) {
4945
applog(LOG_ERR, "Unable to query number of CUDA devices! Is an nVidia driver installed?");
5046
exit(1);
5147
}

0 commit comments

Comments
 (0)