Installing CUDA on Ubuntu 12.04

If you’re looking for a quick and easy way to get started with GPGPU computing, you really can’t go wrong with nVidia’s CUDA. It is a parallel computing architecture that harnesses the power of GPUs in order to achieve significant speedups in problems that would have otherwise taken a significantlylonger time while executing on the CPU. It is the most mature architecture for GPGPU computing, with a wide number of libraries based around it. This guide is going to cover the installation of the CUDA toolkit and SDK on Ubuntu, along with the necessary development drivers.

NOTE – For CUDA to work, you must have an nVidia GPU which is CUDA capable. If you have an ATI GPU, this guide is not for you. You can, however, look into OpenCL.

If your GPU meets the requirements, head over to the CUDA Downloads page and download the toolkit, drivers and SDK from under the Linux section, taking care to choose the 32 or 64-bit version depending on your system. If you’re not sure, run
uname -m
in a terminal. i686 denotes a 32-bit system, and x86_64 denotes a 64-bit one. For the toolkit, I chose the one titled Ubuntu 11.04, although either of the Ubuntu toolkits should work just fine.

Save all three files in an easy to access location, like your Home folder. Do not proceed with this guide until you’ve either memorized the following steps or printed them for easy reference!

STEP I – Driver installation

Make sure the requisite tools are installed using the following command –

sudo apt-get install freeglut3-dev build-essential libx11-dev libxmu-dev libxi-dev libgl1-mesa-glx libglu1-mesa libglu1-mesa-dev

Next, blacklist the required modules (so that they don’t interfere with the driver installation) –

gksu gedit /etc/modprobe.d/blacklist.conf

Add the following lines to the end of the file, one per line –

blacklist amd76x_edac
blacklist vga16fb
blacklist nouveau
blacklist rivafb
blacklist nvidiafb
blacklist rivatv

Save the file and exit gedit.

I would like add a comment right now, in my Ubuntu installation the entry “blacklist amd76x_edac” allready existed. So check if any of the above entries allready exists at your blacklist.conf file.

In order to get rid of any nVidia residuals, run the following command in a terminal –

sudo apt-get remove --purge nvidia*

This may take a while, so be patient. Once it’s done, reboot your machine. At the login screen, don’t login just yet. Press Ctrl+Alt+F1 to switch to a text-based login. Login and switch to the directory which contains the downloaded drivers, toolkit and SDK. Run the following commands –

sudo service lightdm stop
chmod +x devdriver*.run

where devdriver*.run is the full name of your driver. Next, start the installation with –

sudo ./devdriver*.run

Follow the onscreen instructions. If the installer throws up an error about nouveau still running, allow it to create a blacklist for nouveau, quit the installation and reboot. In that case, run the following commands again –

sudo service lightdm stop
sudo ./devdriver*.run

The installation should now proceed smoothly. When it asks you if you want the 32-bit libraries and if you want it to edit xorg.conf to use these drivers by default, allow both.

Reboot once the installation completes.

STEP II – CUDA toolkit installation

Next, enter the following in a terminal window (in the directory where the files are stored) –

chmod +x cudatoolkit*.run
sudo ./cudatoolkit*.run

where cudatoolkit*.run is the full name of the toolkit installer. I recommend leaving the installation path to its default setting (/usr/local/cuda) unless you have a specific reason for not doing so.

STEP III – CUDA SDK installation

Once the toolkit is installed, enter the following in a terminal –

chmod +x gpucomputingsdk*.run
sudo ./gpucomputingsdk*.run

where gpucomputingsdk*.run is the full name of the SDK installer. Again, follow the instructions onscreen to complete the installation.

You’re now ready to journey into the world of CUDA and GPGPU computing. If you’re looking for books on the same, check out this page.

Leave a Reply

Your email address will not be published. Required fields are marked *

Prove me that you are not a robot :) * Time limit is exhausted. Please reload the CAPTCHA.