Ubuntu 12.04. Error: cudaGetDeviceCount returned 30

Could try to first see if you have the missing module by running:

sudo modinfo nvidia-uvm

and post the output. If this provides info on the module, please try to load the module by

sudo modprobe -v nvidia-uvm

And post the output of this command. If the device query does not work after the modprobe command

Update

331 is not specific enough. There was a bug in 331.67 with these properties, that have been fixed in 331.79. Please check your drivers minor version. You can also verify that this is the issue by running:

modprobe --force-modversion nvidia-uvm

Which should bring cuda back online, if an outdated driver is your issue. In that case, you should uopdate your driver!

For more info:

https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=747366