[Solved] cudaGetDevice returned error code 3,

I am getting started with CUDA. I have slackware 14.1 64-bit running on a Dell Precision m4400 machine.
I have installed CUDA toolkit 6.0
I have the NVIDIA driver installed : lspci | grep -i nvidia shows
“01:00.0 VGA compatible controller: NVIDIA Corporation G96GLM [Quadro FX 770M] (rev a1)”
This is the 331.20 driver, I am assuming that CUDA 6 works with this driver version.

I am trying to compile and run the example matrixMul from CUDA-Samples/0_Simple. It compiles correctly, but when I run it using ./matrixMul -device=0 -wA=10 -hA=10 -wB=10 -hB=10, I get an error
“cudaGetDevice returned error code 3, line(396)”

Does anyone have an idea on what is going wrong? Any help is most appreciated.


deviceQuery fails with the following error

"./deviceQuery Starting…

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

cudaGetDeviceCount returned 3
-> initialization error
Result = FAIL"

CUDA 6 on Linux requires a minimum driver version of 331.62

I don’t see slackware listed as a supported distro.

You haven’t indicated how you installed CUDA. I’d suggest starting over with an officially supported distro and using the runfile install method:


Thank you! That fixed it.
I had 331.20, and now after installing 331.67 it works fine.

Though I could not find where the minimum driver version requirement is mentioned.

I infer the minimum driver version from the driver version that is included with the CUDA 6 runfile installer for linux. That particular driver is 331.62. I don’t know for certain that prior driver versions will not work, but I use that as a rule of thumb.