CUDA with Optimus in Linux, root only?

Hi, I’m using a laptop with a GeForce GT 525M card in Ubuntu 10.04. I can only use the Intel card for display, of course, due to the Optimus technology.

I installed the developer drivers, toolkit and SDK code samples for CUDA. However, at the first, only ‘root’ can run the CUDA-enabled applications, e.g. deviceQuery. ONLY after that, normal users are able to run the CUDA-enabled apps. I used ‘lsmod’ to see whether new modules were added in a run launched by a root. But nothing new was found. Can anyone explain this, or give me a workaround to let normal users run the CUDA-enabled apps without a first execution by root?

Thank you in advance!

It has been a long time! I found something interesting, but it’s still a problem.

Before executing a CUDA program as a root, I can not find any nVidia devices on my laptop.

root@ubuntu64:~# ll /dev/nv*

ls: cannot access /dev/nv*: No such file or directory

After executing a CUDA program as a root, e.g. deviceQuery, two new nVidia devices will appear.

root@ubuntu64:~# ll /dev/nv*

crw-rw-rw- 1 root root 195, 0 2011-06-14 14:29 /dev/nvidia0

crw-rw-rw- 1 root root 195, 255 2011-06-14 14:29 /dev/nvidiactl

Since normal users can not modify /dev, and there is no nVidia devices until root executes a CUDA program, normal users can NEVER run a CUDA application before a root’s execution.

Is’t possible to add those devices at the start of the system, or just let normal users be able to add those devices?

It has been a long time! I found something interesting, but it’s still a problem.

Before executing a CUDA program as a root, I can not find any nVidia devices on my laptop.

root@ubuntu64:~# ll /dev/nv*

ls: cannot access /dev/nv*: No such file or directory

After executing a CUDA program as a root, e.g. deviceQuery, two new nVidia devices will appear.

root@ubuntu64:~# ll /dev/nv*

crw-rw-rw- 1 root root 195, 0 2011-06-14 14:29 /dev/nvidia0

crw-rw-rw- 1 root root 195, 255 2011-06-14 14:29 /dev/nvidiactl

Since normal users can not modify /dev, and there is no nVidia devices until root executes a CUDA program, normal users can NEVER run a CUDA application before a root’s execution.

Is’t possible to add those devices at the start of the system, or just let normal users be able to add those devices?

See the release notes for instructions.

See the release notes for instructions.

Thanks a lot, Tera!

find those in the release notes (http://developer.download.nvidia.com/compute/cuda/2_3/toolkit/docs/cudatoolkit_release_notes_linux.txt).

o In order to run CUDA applications, the CUDA module must be
loaded and the entries in /dev created. This may be achieved
by initializing X Windows, or by creating a script to load the
kernel module and create the entries.

An example script (to be run at boot time):

#!/bin/bash

modprobe nvidia

if [ “$?” -eq 0 ]; then

Count the number of NVIDIA controllers found.

N3D=/sbin/lspci | grep -i NVIDIA | grep "3D controller" | wc -l
NVGA=/sbin/lspci | grep -i NVIDIA | 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;
done

mknod -m 666 /dev/nvidiactl c 195 255

else
exit 1
fi

Thanks a lot, Tera!

find those in the release notes (http://developer.download.nvidia.com/compute/cuda/2_3/toolkit/docs/cudatoolkit_release_notes_linux.txt).

o In order to run CUDA applications, the CUDA module must be
loaded and the entries in /dev created. This may be achieved
by initializing X Windows, or by creating a script to load the
kernel module and create the entries.

An example script (to be run at boot time):

#!/bin/bash

modprobe nvidia

if [ “$?” -eq 0 ]; then

Count the number of NVIDIA controllers found.

N3D=/sbin/lspci | grep -i NVIDIA | grep "3D controller" | wc -l
NVGA=/sbin/lspci | grep -i NVIDIA | 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;
done

mknod -m 666 /dev/nvidiactl c 195 255

else
exit 1
fi