Blog InstructionsGNU/Linux

How to install CUDA 5.0 Toolkit on Ubuntu 12.04

This set of instructions explains how to get a complete CUDA 5.0 Toolkit compiler up and running in Ubuntu 12.04 for the x86_64 architecture.
It explains how to avoid getting stuck with a fast booting bios and missing out on loading GRUB by introducing a 3 second timeout. This timeout can be removed after everything is set up.
It also explains how to fix all the linking issues with the toolchains, and how to fix a garbled display when setting up a machine for use with Cuda 5.0 on Ubuntu 12.04.

Be careful when pasting this code, you need to fix the line wrapping yourself. Sorry about that.

cd ~/Desktop
wget http://developer.download.nvidia.com/compute/cuda/5_0/rel-update-1/installers/cuda_5.0.35_linux_64_ubuntu11.10-1.run
chmod +x cuda_5.0.35_linux_64_ubuntu11.10-1.run
sudo apt-get install freeglut3-dev build-essential libx11-dev libxmu-dev libxi-dev libgl1-mesa-glx libglu1-mesa libglu1-mesa-dev
sudo ln -s /usr/lib/x86_64-linux-gnu/libglut.so.3 /usr/lib/libglut.so

#Edit this file:
sudo gedit /etc/modprobe.d/blacklist.conf

#Put this at the end of the file:

blacklist vga16fb
blacklist nouveau
blacklist rivafb
blacklist nvidiafb
blacklist rivatv

#Save and close.

#Edit this file:
sudo gedit /etc/default/grub

#Put these settings in the file:

GRUB_HIDDEN_TIMEOUT=3
GRUB_HIDDEN_TIMEOUT_QUIET=false
GRUB_CMDLINE_LINUX_DEFAULT=”nomodeset” # used to be quiet splash
GRUB_TERMINAL=console # fixes stupid slow scrolling problem in grub

sudo update-grub

#Reboot

#Hit LEFT SHIFT when 3 second countdown
e

#Append this word to the end of the linux boot option:
text

#Hit Ctrl-X to boot

#Login in text mode:

#Remove all nvidia crap
sudo apt-get remove --purge nvidia-*

#BACKUP YOUR xorg.conf then do this:

sudo dpkg-reconfigure xserver-xorg
sudo apt-get install -V nvidia-experimental-310 nvidia-experimental-310-dev
sudo ln -s /usr/lib/nvidia-experimental-310/libcuda.so /lib/libcuda.so

#Restore your xorg.conf

#Check your version of gcc/g++, you need 4.5
gcc -v
sudo apt-get install gcc-4.5
sudo apt-get install g++-4.5
cd /usr/bin
sudo rm gcc
sudo ln -s gcc-4.5 gcc
sudo rm g++
sudo ln -s g++-4.5 g++

#Now install Cuda 5.0 – BUT DON’T INSTALL BUNDLED NVIDIA DRIVER!
cd ~/Desktop
sudo ./cuda_5.0.35_linux_64_ubuntu11.10-1.run

#Fix up linker options by creating this new file:

sudo nano /etc/ld.so.conf.d/cuda50.conf

#Throw in these two lines, save and quit

/lib
/usr/local/cuda-5.0/lib

#Update linker config
sudo ldconfig

#Add this to your path (or whichever place you told it to install):
sudo gedit ~/.bashrc

export PATH=${PATH}:/usr/local/cuda-5.0/bin

Now you should be able to compile Cuda 5.0 Samples or your own project using Ubuntu 12.04!

2 thoughts on “How to install CUDA 5.0 Toolkit on Ubuntu 12.04

Leave a Reply

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