CUDA in Debian Linux (doesn't work)

I use Debian testing 64 bit with Nvidia 740m gt (drivers: 331.67) with Bumblebee.
I’ve installed nvidia-cuda-toolkit too.
The problems is that my CUDA doesn’t work. For example, if I run “optirun blender” it works… but without CUDA support, and this is the output in my terminal:
$ optirun blender
Color management: using fallback mode for management
connect failed: No such file or directory
modprobe: ERROR: could not insert ‘nvidia_uvm’: Invalid argument
CUDA cuInit: Unknown error

One week ago I solved this problem in Gentoo Linux simply installing the nvidia-cuda-toolkit from Gentoo’s packages. In Windows 7 it works too.

Maybe I must tell Blender or nvidia-drivers where to find the cuda-toolkit … I don’t know …

The error message is pointing you to the solution. Some of the latest NVIDIA drivers require the nvidia-uvm module to be compiled and available, but due to some old patches being applied to the xorg-edgers ppa drivers, the module building fails.

Assuming you have installed it with the usual apt-get install nvidia-331 bumblebee, also install nvidia-331-uvm and libcuda1-331, as apparently the cuda library sometimes does not get installed automatically either.

If nvidia-331-uvm errors out while building, you’ll need to follow posts 8 and 9 here:
[url]334.21 driver returns 999 on cuInit (CUDA) - Linux - NVIDIA Developer Forums

mrfabiolo, you can tell me how did that installation?

i’d like to echo rygle 's question, given that Debian is not specifically listed in the list of “supported platforms” and Debian != Ubuntu.

I know I’m late to the party, but I may have a solution for others with this problem.
I had a similar issue with matlab on my Debian machine when I would use gpuArrays. The console would say the following:

modprobe: ERROR: could not insert 'nvidia_current_uvm': Operation not permitted
modprobe: ERROR: ../libkmod/libkmod-module.c:977 command_do() Error running install command for nvidia_uvm
modprobe: ERROR: could not insert 'nvidia_uvm': Operation not permitted

and matlab Command Window would report

Error using gpuArray
An unexpected error occurred during CUDA execution. The CUDA error was:
CUDA_ERROR_UNKNOWN

SOLUTION

The solution to my problem, and most likely your problem, is that you need the nvidia_uvm running.
Matlab (and your program) tried to start it, but doesn’t have permission to do so.

Assuming you already have the proper cuda packages, nvidia-cuda-dev or libcuda1, installed you can simply run one of the following commands to start the nvidia_uvm module:

sudo modprobe nvidia_current_uvm

OR

sudo modprobe nvidia_uvm

If this fixes the issue, you can have kmod start the module automatically at boot by placing the following lines in /etc/modules (ignore the line numbers):

# Needed for programs using libCUDA
nvidia_current_uvm

If you used modprobe nvidia_uvm previously, replace the name in the above snippet.

You can verify that the nvidia_uvm module has started by running lsmod | grep nvidia and checking that you see nvidia_uvm in the output. If you do not see the module in the output, I would sift through the output of dmesg | grep -i nvidia and look for any error messages pertaining to that module.

Ubuntu is a Debian-based distribution. So you can quite often just pick Ubuntu packages and install them on Debian, too.