Nvidia CUDA 5.5/Ubuntu 13.10 Saucy Salamander

Posted in Articles on Jan 23, 2014

Hey guys. Had a small amount of trouble recently installing cuda 5.5 on Ubuntu 13.10 Saucy Salamander recently, and none of the guides I saw seemed to give the complete story, as cuda 5.5 isn't compatible with Saucy's default gcc version. This is actually more of a guide on how to use update-alternatives than anything specific for cuda itself. Anyway, onwards...

It's actually a pretty simple process. Following instructions found here and here, I was able to see that the process should be fairly simple, but it still wouldn't install. The issue was it didn't support gcc-4.8. Reading into it, I needed to be using gcc 4.7.2 or before, so neither Saucy's 4.8 (4.8.1) or 4.7 (4.7.3) options would work. I needed gcc-4.6 to be picked up by the OS as the default compiler. Cue update-alternatives.

First up you need to install the gcc-4.6 binaries. This is as simple as:

apt-get install gcc-4.6 g++-4.6

Now you need to set up gcc (and g++ if you like) with their alternatives, and defaults.

sudo update-alternatives --remove-all gcc
sudo update-alternatives --remove-all g++
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.6 30
sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-4.6 30
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.7 20
sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-4.7 20
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.8 10
sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-4.8 10

Now you have all the alternatives you may need. Switching between them is very easy; just use:

sudo update-alternatives --config gcc # (replace gcc with g++ to configure that if you want, too).

Then select the number in the left-hand "Selection" column that refers to gcc-4.6. This will allow you to follow the processes in the linked install guides with ease.

Thanks for reading, and I hope this helps some of you out!

n00b