cuDeviceComputeCapability Is Undefined?


I’m having trouble understanding why I can’t get a simple device information CUDA program to run? I added a line that returns my device’s compute capability, and the linker is complaining that is it an undefined reference. I checked my $PATH and $LD_LIBRARY_PATH, and rgrep returns matches of cuDeviceComputeCapability in, which is in the path variables…

echo $PATH --> /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/cuda/bin

echo $LD_LIBRARY_PATH --> /usr/local/cuda/lib

rgrep cuDeviceComputeCapability /usr/local/cuda/lib -->

Binary file /usr/local/cuda/lib/ matches

Binary file /usr/local/cuda/lib/ matche…

Help would be appreciated thanks!


#include <stdio.h>

#include "cuda.h"

int main(void)


  struct cudaDeviceProp deviceProp;

  int device = 0;

  char *test;

  int m, n;

if(cudaGetDeviceProperties(&deviceProp,device) == cudaSuccess)


	 cuDeviceComputeCapability(&m, &n, device);

	 unsigned long memory = (unsigned long)deviceProp.totalGlobalMem;

	 memory = memory / 1024;

	 memory = memory / 1024;

	 printf("Device Name: %s",;

	 printf("Device Computer Capability: %d.%d", m, n);

	 printf("\nMem Size: %lu \n", memory);

	 printf("Max Threads: %d\n", deviceProp.maxThreadsPerBlock);

	 printf("Max Threads Dim[x?]: %d\n", deviceProp.maxThreadsDim[0]);

	 printf("Max Threads Dim[y?]: %d\n", deviceProp.maxThreadsDim[1]);

	 printf("Max Threads Dim[z?]: %d\n", deviceProp.maxThreadsDim[2]);

	 printf("Max Grid Size[x?]: %d\n", deviceProp.maxGridSize[0]);

	 printf("Max Grid Size[y?]: %d\n", deviceProp.maxGridSize[1]);

	 printf("Max Grid Size[z?]: %d\n", deviceProp.maxGridSize[2]);



error msg:

/tmp/tmpxft_00006a8d_00000000-11_deviceInfo.o: In function `main':

tmpxft_00006a8d_00000000-10_deviceInfo.ii:(.text+0x18c): undefined reference to `cuDeviceComputeCapability'

collect2: ld returned 1 exit status

You’re mixing the driver API and the runtime API. cuda* calls are from the runtime, and cu* calls are from the driver API. Link with libcuda to make that work, although can’t you just pull compute capability out of the deviceProp structure?

Looking at the CUDA reference manual, the structure doesn’t seem to have a major and minor revision. I am confused as to why I have to link it at the console… is one of my environment variables incorrect or something?\

!! Forgot to thank you, your advice was spot on. Thank you very much for the help =D.

major and minor are in the runtime API device property struct…

I’m glad I said that, thank you for pointing that out to me!