Ubuntu – Installing and testing CUDA in Ubuntu 14.04

aptcudanvidiasoftware installation

I am uncertain about how to install CUDA in my system.
looking around there are many tutorials about cuda on 12.04 LTS and a few on 13.04 and 13.10, but they all talk about acquiring a deb package from the NVidia CUDA developer zone.

Well NVidia does not offer a Debian package for 14.04 as of yet.

However, there is a promising package in apt repository: nvidia-cuda-toolkit.

The problem is that I didn't find any example with it. At least not the examples that are referred to in cuda6 online documentation section 4.11.

I should mention that the toolkit installed is v5.5, not v6 but I haven't found documentation for cuda v5.5 on the NVidia website.

So I can verify that nvcc is there, but nothing further than that. How can I get some examples to run to verify the CUDA is installed properly?

Best Answer

I got Cuda6 working on Lubuntu 14.04. This already had build-essentials installed, so if you're using a fresh install, you should probably install it:

apt-get install build-essential

Download the cuda6 run package (6.0.37 at the current time of writing) to ~/Downloads:

Open up a terminal and extract the separate installers via:

mkdir ~/Downloads/nvidia_installers;
cd ~/Downloads
./cuda_6.0.37_linux_64.run -extract=~/Downloads/nvidia_installers;

(I tried running the .run file directly, but it kept screwing up my Xorg install and would never let X run. I believe it is a config issue between driver versions: those installed by apt-get nvidia-331-updates and the cuda*.run driver.)

Completely uninstall anything in the Ubuntu repositories with nvidia-*. I used synaptic and did a purge, AKA completely uninstall programs and configuration.

sudo apt-get --purge remove "nvidia-*"

Have these instructions handy as we need to kill X install the driver. Press CTL + ALT + F1 to drop to the physical terminal and log in.

cd ~/Downloads/nvidia_installers;
sudo service lightdm stop
sudo killall Xorg
sudo ./NVIDIA-Linux-x86_64-331.62.run 

Accept the EULA and install the driver. I would recommend letting it update Xorg config files.

After that installer finishes, turn on the nvidia module and install CUDA.

sudo modprobe nvidia
sudo ./cuda-linux64-rel-6.0.37-18176142.run
sudo ./cuda-samples-linux-6.0.37-18176142.run

test if the drivers are working by going to your sample directory

cd /usr/local/cuda/samples
sudo chown -R <username>:<usergroup> .
cd 1_Utilities/deviceQuery
make .

Worked for me at this point. Now restart X

sudo service lightdm start

You should be able to do

lsmod | grep nv

and see a line with nvidia listed. Don't forget to log back out of your physical terminal if it all worked.


In my case it was necessary to add the folder that contains the executable to your $PATH.

One way of doing it is to edit the ~/.bashrc file in your Home folder. Add a line to your .bashrc (modify the location if you changed the default CUDA installation folder)

export PATH=/usr/local/cuda-6.0/bin:$PATH

Save the file and then source your .bashrc by typing

source .bashrc

when in your home folder.

Related Question