58

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?

4
  • @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?
    – TinyEpic
    May 9, 2014 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? May 15, 2014 at 21:56
  • Probably need to add the nvidia repo to your sources Jul 1, 2014 at 13:41
  • 3
    @NickolaiLeschov nvidia-cuda-toolkit is part of multiverse, which you may need to enable. Oct 2, 2015 at 4:15

8 Answers 8

49

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

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.

APPENDIX

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.

8
  • 1
    @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. May 12, 2014 at 21:23
  • 1
    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. May 15, 2014 at 22:00
  • When I install driver with sudo ./NVIDIA-Linux-x86_64-331.62.run, 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. May 15, 2014 at 22:06
  • The correct build essential package name is "build-essential" (no s).
    – hookenz
    May 26, 2014 at 3:57
  • 3
    It is not necessary to extract the .run file. Instead, just supply the appropriate command line options. E.g., sudo ./cuda_6.0.37_linux_64.run -driver -silent to install the driver, sudo ./cuda_6.0.37_linux_64.run -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 cuda-install-samples-6.0.sh in its bin directory to copy them to a local location.
    – Bart
    Jul 23, 2014 at 22:58
30

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.

2
20

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.

0
3

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 your Ubuntu release 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!

1

I got the cuda 6 release installed and the samples to work on ubuntu 14.04. First I installed the nvidia driver 334.21 (NVIDIA-Linux-x86_64-334.21.run), then just used the cuda_6.0.37_linux_64.run script.

First I downloaded NVIDIA-Linux-x86_64-334.21.run 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 ./NVIDIA-Linux-x86_64-334.21.run, 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 cuda_6.0.37_linux_64.run from nvidia, and installed it using sudo cuda_6.0.37_linux_64.run --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 libcurand.so.6.0 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

1

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.

1

I installed cuda 6 using the package(cuda_6.0.37_linux_64.run) from here . 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.

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

I installed and tested it using this.

https://gist.github.com/mGalarnyk/f3b78fb90ca58855bba01738dd88ef2c#file-install_cuda_7-5_ubuntu_14_04

# http://developer.download.nvidia.com/compute/cuda/repos/ubuntu1404/x86_64/
wget http://developer.download.nvidia.com/compute/cuda/repos/ubuntu1404/x86_64/cuda-repo-ubuntu1404_7.5-18_amd64.deb
sudo dpkg -i cuda-repo-ubuntu1404_7.5-18_amd64.deb
rm cuda-repo-ubuntu1404_7.5-18_amd64.deb
echo 'export CUDA_HOME=/usr/local/cuda
export CUDA_ROOT=/usr/local/cuda
export PATH=$PATH:$CUDA_ROOT/bin:$HOME/bin
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$CUDA_ROOT/lib64
' >> ~/.bashrc

# Let terminal know of the changes to the .bashrc file
source .bashrc

sudo apt-get update 

# y flag just says yes to all prompts
sudo apt-get install -y cuda

# Check if installation is successful by running the next line
# nvcc -V

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .