This post is now outdated. Please refer this link for an updated version.
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 significantly longer 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.
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
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 -
Save the file and exit gedit.
Update – WARNING – Reader Bart points out in the comments that the purge nvidia* command resulted in a prompt to remove ubuntu-desktop (for him). If this occurs, do not proceed or it will wreck your GUI. You could reinstall ubuntu-desktop after the entire process but I’m not sure if that’ll affect your data (configs for each app).
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 -
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
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
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
Update – I’ve just found out that the SDK must be installed as a regular user (and not as root) according to the “nVidia CUDA C Getting Started Guide for Linux” (refer pg 11). Apparently, this is to prevent access issues with the SDK files.
Also, readers Fernest Hall and Adub have mentioned tips in the comments that might be useful for some readers, although they haven’t worked for me. Thanks guys!
Update 2 – Reader Alan has mentioned a link in the comment section. Although I haven’t checked it out yet, it might work for you.
Once the toolkit is installed, enter the following in a terminal -
chmod +x 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.
Credit for the driver installation goes to this awesome video.