I spent a considerable amount of time getting this to work. None of the tutorials online worked. What I found was so simple….but this had happened a long time ago and I just tried it.
For cuda to work, you have to have the /dev/nvidia* devices. However, just because you have 1 nvidia card doesn’t mean it will always be /dev/nvidia1 So my fix was this:
First Installing Bumblebee Repo + Packages
sudo add-apt-repository ppa:bumblebee/stable sudo add-apt-repository ppa:ubuntu-x-swat/x-updates sudo apt-get purge nvidia* sudo apt-get update sudo apt-get install bumblebee bumblebee-nvidia linux-headers-generic
Next, you will need to blacklist the nouveou module:
sudo sed -i 's/quiet splash/quiet splash nouveau.blacklist=1/g' /etc/default/grub
Reboot your computer.
After you reboot, you should be able to run optirun glxgears and it should work.
Cuda Package Installation
Go the the nvidia cuda website and download the latest version for ubuntu. When you do the installation, skip the driver installation. Make sure you add the library stuff to the bottom of your .bashrc file:
PATH=$PATH:/usr/local/cuda/bin LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/cuda/lib64 export PATH export LD_LIBRARY_PATH
After it is installed, run the following commands to set up the dev devices properly:
sudo /sbin/rmmod nvidia sudo mknod -m 666 /dev/nvidia0 c 195 0 sudo mknod -m 666 /dev/nvidiactl c 195 255 sudo mknod -m 666 /dev/nvidia1 c 195 1 sudo /sbin/modprobe nvidia
Now you can compile a cuda app and test your device:
cd /usr/local/cuda/samples/1_Utilities/deviceQuery sudo make ./deviceQuery
./deviceQuery Starting... CUDA Device Query (Runtime API) version (CUDART static linking) Detected 1 CUDA Capable device(s) Device 0: "GeForce GTX 660M" CUDA Driver Version / Runtime Version 5.0 / 5.0 CUDA Capability Major/Minor version number: 3.0 Total amount of global memory: 2048 MBytes (2147287040 bytes) ( 2) Multiprocessors x (192) CUDA Cores/MP: 384 CUDA Cores GPU Clock rate: 950 MHz (0.95 GHz) Memory Clock rate: 2500 Mhz Memory Bus Width: 128-bit L2 Cache Size: 262144 bytes Max Texture Dimension Size (x,y,z) 1D=(65536), 2D=(65536,65536), 3D=(4096,4096,4096) Max Layered Texture Size (dim) x layers 1D=(16384) x 2048, 2D=(16384,16384) x 2048 Total amount of constant memory: 65536 bytes Total amount of shared memory per block: 49152 bytes Total number of registers available per block: 65536 Warp size: 32 Maximum number of threads per multiprocessor: 2048 Maximum number of threads per block: 1024 Maximum sizes of each dimension of a block: 1024 x 1024 x 64 Maximum sizes of each dimension of a grid: 2147483647 x 65535 x 65535 Maximum memory pitch: 2147483647 bytes Texture alignment: 512 bytes Concurrent copy and kernel execution: Yes with 1 copy engine(s) Run time limit on kernels: No Integrated GPU sharing Host Memory: No Support host page-locked memory mapping: Yes Alignment requirement for Surfaces: Yes Device has ECC support: Disabled Device supports Unified Addressing (UVA): Yes Device PCI Bus ID / PCI location ID: 1 / 0 Compute Mode: < Default (multiple host threads can use ::cudaSetDevice() with device simultaneously) > deviceQuery, CUDA Driver = CUDART, CUDA Driver Version = 5.0, CUDA Runtime Version = 5.0, NumDevs = 1, Device0 = GeForce GTX 660M
Once cuda is verified as working…..now make sure pyrit can see the device:
$ pyrit list_cores Pyrit 0.4.1-dev (svn r308) (C) 2008-2011 Lukas Lueg http://pyrit.googlecode.com This code is distributed under the GNU General Public License v3+ The following cores seem available... #1: 'CUDA-Device #1 'GeForce GTX 660M'' #2: 'CPU-Core (SSE2/AES)' #3: 'CPU-Core (SSE2/AES)' #4: 'CPU-Core (SSE2/AES)' #5: 'CPU-Core (SSE2/AES)' #6: 'CPU-Core (SSE2/AES)' #7: 'CPU-Core (SSE2/AES)' #8: 'CPU-Core (SSE2/AES)'