Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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?

share|improve this question
@Chris.Wilson I was following your instruction and everything was fine; but at the ./deviceQuery stage my machine said no CUDA-capable device is detected. My machine has Nvidia GTX780. Do you have any idea about this problem? – Yanagiba May 9 '14 at 11:06
My Ubuntu 14.04 complains: "E: Unable to locate package nvidia-cuda-toolkit". Maybe because I have a 64-bit server distribution? Do you know how I can install CUDA on Ubuntu 14.04 64-bit server? – Nickolai Leschov May 15 '14 at 21:56
Probably need to add the nvidia repo to your sources – stealthcopter Jul 1 '14 at 13:41
@NickolaiLeschov nvidia-cuda-toolkit is part of multiverse, which you may need to enable. – 200_success Oct 2 '15 at 4:15
up vote 41 down vote accepted

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
./ -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. Hit CTL+ALT+F1 to drop to the physical terminal and log in.

cd ~/Downloads/nvidia_installers;
sudo service lightdm stop
sudo killall Xorg
sudo ./ 

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 ./
sudo ./

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.

share|improve this answer
@tohnperfect: you might need to modprobe nvidia after the driver install so that the ./deviceQuery actually hits the nvidia driver. Did it happen to work after a reboot? If so, the nvidia driver probably wasn't actually loaded. – Chris.Wilson May 12 '14 at 21:23
Notes: 1) On my system the package is called build-essential, not build-essentials 2) I don't have X to stop, as I run a server variant without X 3) sudo modprobe nvidia goes FATAL at this point, looks like the driver wasn't installed? My version of the recipe is here, but it doesn't work. – Nickolai Leschov May 15 '14 at 22:00
When I install driver with sudo ./, I get an this error. In /var/log/nvidia-installer.log I see the following lines. When I try make oldconfig && make prepare I get this. At this point I gave up. – Nickolai Leschov May 15 '14 at 22:06
The correct build essential package name is "build-essential" (no s). – Matt H May 26 '14 at 3:57
It is not necessary to extract the .run file. Instead, just supply the appropriate command line options. E.g., sudo ./ -driver -silent to install the driver, sudo ./ -toolkit -samples -silent -override to install the toolkit and samples (use -help for more options). Also, better not chmod the samples directly: the toolkit contains a script in its bin directory to copy them to a local location. – Bart Jul 23 '14 at 22:58

For CUDA-6.5 I followed this simple tutorial:

Download the .deb here then

sudo dpkg -i cuda-repo-ubuntu1404_6.5-14_amd64.deb
sudo apt-get update
sudo apt-get install cuda
echo 'export PATH=/usr/local/cuda-6.5/bin:$PATH   #CUDA' >> ~/.bashrc

That's everything I needed to start coding on a fresh 14.04.1 install with my GTX 750ti. It installs the nvidia-340 driver. deviceQuery and all of the other samples ran properly after I compiled them.

share|improve this answer
This worked well for me (got CUDA 7.0). It took a long time to download the files (during the apt-get install) but it now works. – stvn66 Jun 9 '15 at 21:14

I have installed the nvidia-cuda-toolkit package this morning on a fresh 14.04. I also installed the nvidia driver (version 331.38 marked as tested) from the additional driver interface.

sudo apt-get install nvidia-cuda-toolkit

Up to now everything seems to work well (nvcc is here, display is correct). You need to restart to use the new driver.

As you mentioned this is CUDA 5.5 but in my case it's not a problem.

share|improve this answer

I installed cuda 6 using the package( from today. Unfortunately, I failed to install the driver. Although Toolkit(CUDA 6) was installed, it didn't pass the sample test:

./deviceQuery Starting...

CUDA Device Query (Runtime API) version (CUDART static linking)

cudaGetDeviceCount returned 3 -> initialization error Result = FAIL

I've also tested nvidia-334, nvidia-371 from ppa:xorg-edgers/ppa. The results is worse. Both CUDA 5 and CUDA 6 failed to pass the sample test.

In summary, CUDA 6 is not working on Ubuntu 14.04. But CUDA 5.5+nvidia-331 is OK. And you can verify cuda by testing cuda-5.5 samples.

share|improve this answer
cuda-5.5 samples are in /usr/share/doc/? – nass Apr 30 '14 at 13:14
It depends. Please check /usr/local/cuda/samples/. It it doesn't exist, you can download .run from and only install samples. It'll be installed to ~/NVIDIA_CUDA-5.5_Samples/ by default. – Coiby May 1 '14 at 1:01

I got the cuda 6 release installed and the samples to work on ubuntu 14.04. First I installed the nvidia driver 334.21 (, then just used the script.

First I downloaded from nvidia, then logged out of the ubuntu desktop to the login screen. Then logged in remotely over ssh from my laptop and shutdown lightdm sudo service lightdm stop to stop X running, then ran the install script sudo ./, then restarted lightdm sudo service lightdm start. Then rebooted. Verified that hardware acceleration was working by running the UrbanTerror game (not suitable for young children!! but now running at 90+ fps instead of 20fps). I also installed libXi and libXmu packages through synaptic.

Then to installed cuda 6: I downloaded from nvidia, and installed it using sudo --override otherwise it complained about not supporting the environment. I think I had to tell it not to overwrite the 334 driver during the install, otherwise accepted defaults. To compile examples I did cd ~/NVIDIA_CUDA-6.0_Samples and make. The examples appeared under bin, a few needed to be run as eg LD_LIBRARY_PATH=/usr/local/cuda-6.0/lib64 ./MersenneTwisterGP11213 otherwise they couldn't find the library, but no other problems I noticed.

I don't know if installing using --override is risky, but so far so good for my install.

my system: ubuntu 14.04, AMD FX-8350 CPU, nvidia GTX750 GPU (Maxwell architecture)

I've got the build-essentials package installed, but not nvidia-cuda-toolkit

share|improve this answer

Quick and easy solution that worked for me (cuda 5.5, Lubuntu 14.04 64-bit):

Make sure you're using nvidia's propietary driver (331.38 for me) from Start menu-> Preferences->Software & Updates.

Download the .deb package for ubuntu 13.04 from Nvidia's site.

Add repo

sudo dpkg -i cuda-repo-ubuntu1304_6.0-37_amd64.deb

sudo apt-get update

Get dependencies

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

Get the toolkit

sudo apt-get install nvidia-cuda-toolkit

(Optional) Get nsight IDE

sudo apt-get install nvidia-nsight

And you're ready to go!

share|improve this answer

I got CUDA 6.0 up and working on 14.04 using the following steps.

Install the nvidia-331, nvidia-331-dev and nvidia-331-uvm packages from xorg-edgers using instructions for adding the ppa from here.

Install CUDA 6.0 using the "-extract" method above, except ignore the steps for installing the driver and instead rely on the packages. Only install the compiler and samples.

share|improve this answer

protected by Community Nov 14 '14 at 19:34

Thank you for your interest in this question. Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).

Would you like to answer one of these unanswered questions instead?

Not the answer you're looking for? Browse other questions tagged or ask your own question.