Configuring CUDA in Ubuntu 13.04

Some months ago I bought a new Desktop PC with the aim to start learning about CUDA programming. The new PC had an integrated INTEL video card, and a NVIDIA GeForce GT620. The idea was use the integrated video card for the xserver, leaving the GeForce dedicated to run simulations.

When I tried to install the driver for  the NV card, things started to go wrong, because the NV driver replace the mesa OpenGL  libraries with theirs. Because the xserver actually works on the Intel video card, which is incompatible with the proprietary openGL libraries, openGL stopped working and as a result, also Unity got broken.


After a couple of evenings trying to make it work, I found that the trick to make all be working  is, after the installation of the nvidia driver, reinstall the original  mesa glx libraries. Here is the right procedure:


* Uninstall all NV components on the system

   # sudo nvidia-uninstall
   # sudo apt-get purge nvidia*

   
* Download the last official drivers  from the NV web site: http://www.nvidia.com/object/linux-display-amd64-319.60-driver.html


* Install the required packages for the installer
 
   # sudo apt-get install linux-headers-`uname -r`


* The next steps requires the xserver stopped. So,   Go to a terminal (Ctrl + Alt + F1) and stop the xserver. For instance,

     # sudo stop lightdm


* Install driver

# cd path/where/you/save/drivers
# sudo chmod +x  NVIDIA-Linux-x86_64-319.60.run
# sudo ./NVIDIA-Linux-x86_64-319.60.run


* At this point, the driver is OK, but our xserver would show problems with the Open GL libraries.  However, the GPU is ready:

# sudo nvidia-smi

should show the status of the GPU.

* Now, to avoid the problem with the Open GL libraries, we (re) install  both our xserver and the mesa libraries:

# sudo apt-get  install --reinstall xserver-xorg-core  xserver-xorg-  libgl1-mesa-glx


* Reboot the system

Now, you can install the CUDA Toolkit, avoiding to reinstall the NV drivers...