Sunday, May 20, 2012

cudaGetDeviceCount returned 38

The machine was initially configured to use the NVIDIA card to provide video output and the IGD (integrated graphic device) comes with the board is disabled. To make full use of the GPU to provide computation power, I have to re-configure the BIOS to use the IGD for video output and leave NVIDIA card for computation.

However, after installing the NVIDIA driver, CUDA 4.2 and SDK on Ubuntu 12.04, the test program deviceQuery cannot find the CUDA device:

$. / DeviceQuery
 [DeviceQuery] starting ...
 . / DeviceQuery Starting ...

  CUDA Device Query (Runtime API) version (CUDART static linking)

 cudaGetDeviceCount returned 38
 -> No CUDA-capable device is detected
 [DeviceQuery] test results ...

 Press ENTER to exit ...

Checking the device:

$ lspci | grep -i NVIDIA
01:00.0 VGA compatible controller: NVIDIA Corporation Tesla C2075 (rev a1)
With the help of the post: and Google Translate, finally realized the problem is actually stated in the installation doc:

4. If you do not use a GUI environment, ensure that the device files /dev/nvidia*
  exist and have the correct file permissions. (This would be done automatically when
 initializing a GUI environment.) This can be done creating a startup script like the
following to load the driver kernel module and create the entries as a superuser at
boot time:

/sbin/modprobe nvidia

if [ "$?" -eq 0 ]; then
    # Count the number of NVIDIA controllers found.
    NVDEVS=`lspci | grep -i NVIDIA`
    N3D=`echo "$NVDEVS" | grep "3D controller" | wc -l`
    NVGA=`echo "$NVDEVS" | grep "VGA compatible controller" | wc -l`
    N=`expr $N3D + $NVGA - 1`
    for i in `seq 0 $N`; do
        mknod -m 666 /dev/nvidia$i c 195 $i
    mknod -m 666 /dev/nvidiactl c 195 255
    exit 1

Thus to solve the problem: add the above scripts to /etc/rc.local as a startup script.

1 comment:

  1. Hey mate,

    Have you by any chance tried out cuda 5.0?

    I've taken all steps with a CUDA-capable GPU (according to their website) and I'm getting this same error.

    Please let me know if you can help. I followed your instructions and added the script to rc.local.