How to install CUDA Toolkit 7/8/9 on Debian 8 (Jessie) or 9 (Stretch)?

How to install Cuda Toolkit 7.0 or 8 on Debian 8?

I know that Debian 8 comes with the option to download and install CUDA Toolkit 6.0 using apt-get install nvidia-cuda-toolkit, but how do you do this for CUDA toolkit version 7.0 or 8?

I tried installing using the Ubuntu installers, as described below:

sudo wget

dpkg -i cuda-repo-ubuntu1404_7.0-28_amd64.deb

sudo apt-get update

sudo apt-get install -y cuda

However it did not work and the following message was returned:

Reading package lists... Done
Building dependency tree       
Reading state information... Done
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:

The following packages have unmet dependencies:
 cuda : Depends: cuda-7-0 (= 7.0-28) but it is not going to be installed
E: Unable to correct problems, you have held broken packages.
Asked By: Greg


Try to use Network Installers for Ubuntu from this page:

Installers for Ubuntu 14.* should be enough compatible.

Answered By: Tomasz Klim

The following instructions are valid for CUDA 7.0, 7.5, and several previous (and probably later) versions. As far as Debian distributions, they’re valid for Jessie and Stretch and probably other versions. They assume an amd64 (x86_64) architecture, but you can easily adapt them for x86 (x86_32).

Installation prerequisites

  • g++ – You should use the newest GCC version supported by your version of CUDA. For CUDA 7.x this would be version 4.9.3, last of the 4.x line; for CUDA 8.0, GCC 5.x versions are supported. If your distribution uses GCC 5.x by default, use that, otherwise GCC 5.4.0 should do. Earlier versions are usable but I wouldn’t recommend them, if only for the better modern-C++ feature support for host-side code.
  • gcc – comes with g++. I even think CMake might default to having nvcc invoke gcc rather than g++ in some cases with a -x switch (but not sure about this).
  • libGLU – Mesa OpenGL libraries (+ development files?)
  • libXi – X Window System Xinput extension libraries (+ development files?)
  • libXmu – X Window System “miscellaneous utilities” library (+ development files?)
  • Linux kernel – headers for the kernel version you’re running.

If you want a list of specific packages – well, that depends on exactly which distribution you’re using. But you can try the following (for CUDA 7.x):

sudo apt-get install gcc g++ gcc-4.9 g++-4.9 libxi libxi6 libxi-dev libglu1-mesa libglu1-mesa-dev libxmu6 libxmu6-dev linux-headers-amd64 linux-source

And you might add some -dbg versions of those packages for debugging symbols.

I’m pretty sure this covers it all – but I might have missed something I just had installed already. Also, CUDA can work with clang, at least experimentally, but I haven’t tried that.

Installing the CUDA kernel driver

  1. Go to NVIDIA’s CUDA Downloads page.
  2. Choose Linux > x86_64 > Ubuntu , and then whatever latest version they have (at the time of writing: Ubuntu 15.04).
  3. Choose the .run file option.
  4. Download the .run file (currently this one). Make sure not to put it in /tmp.
  5. Make the .run file executable: chmod a+x
  6. Become root.
  7. Execute the .run file: Pretend to accept their silly shrink-wrap license; say “yes” to installing just the NVIDIA kernel driver, and say “no” to everything else.

The installation should tell you it expects to have installed the NVIDIA kernel driver, but that you should reboot before continuing/retrying the toolkit installation. So…

  1. Having apparently succeeded, reboot.

Installing CUDA itself

  1. Be root.
  2. Locate and execute
  3. This time around, say No to installing the driver, but Yes to installing everything else, and accept the default paths (or change them, whatever works for you).

The installer is likely to now fail. That is a good thing assuming it’s the kind of failure we expect: It should tell you your compiler version is not supported – CUDA 7.0 or 7.5 supports up to gcc 4.9 and you have some 5.x version by default. Now, if you get a message about missing libraries, that means my instructions above regarding prerequisites somehow failed, and you should comment here so I can fix them. Assuming you got the “good failure”, proceed to:

  1. Re-invoke the .run file, this time with the –override option.
  2. Make the same choices as in step 11.

CUDA should now be installed, by default under /usr/local/cuda (that’s a symlink). But we’re not done!

Directing NVIDIA’s nvcc compiler to use the right g++ version

NVIDIA’s CUDA compiler actually calls g++ as part of the linking process and/or to compile actual C++ rather than .cu files. I think. Anyway, it defaults to running whatever’s in your path as g++; but if you place another g++ under /usr/local/cuda/bin, it will use that first! So…

  1. Execute symlink /usr/bin/g++-4.9 /usr/local/cuda/bin/g++ (and for good measure, maybe also symlink /usr/bin/gcc-4.9 /usr/local/cuda/bin/gcc.

That’s it.

Trying out the installation

  1. cd /root/NVIDIA_CUDA-7.5_Samples/0_Simple/vectorAdd
  2. make

The build should conclude successfully, and when you do

  1. ./vectorAdd

you should get the following output:

root@mymachine:~/NVIDIA_CUDA-7.5_Samples/0_Simple/vectorAdd# ./vectorAdd
[Vector addition of 50000 elements]
Copy input data from the host memory to the CUDA device
CUDA kernel launch with 196 blocks of 256 threads
Copy output data from the CUDA device to the host memory


  • You don’t need to install the NVIDIA GDK (GPU Development Kit), but it doesn’t hurt and it might be useful for some. Install it to the root directory of your system; it’s pretty safe and there’s an uninstaller afterwards: /usr/bin/ In CUDA 8 it’s already integrated into CUDA itself IIANM.
  • Do not install additional packages with names like nvidia-… or cuda… ; they might not hurt but they’ll certainly not help.
  • Before doing any of these things, you might want to make sure your GPU is recognized at all, using lspci | grep -i nvidia.
Answered By: einpoklum

I think you should do it using backports, I’m actually smoothly installing nvidia-cuda-toolkit 7.5 on debian jessie.

Add backports, non free, to your /etc/apt/sources.list. For me (on jessie) I just put this on the bottom of my file:

# jessie-backports
deb jessie-backports main contrib non-free

saved, apt-get update, and finally:

apt-get install -t jessie-backports nvidia-cuda-toolkit
Answered By: Poso

After adding contrib and non-free repos to sources.list and running apt-get update, CUDA Toolkit is in Synaptic under nvidia-cuda-toolkit.

Answered By: Default picture

With Debian 9 “stretch” with an older GPU (GT 720) additional steps are needed. I see someone above (@celavek) had this, so I’ll fill in what worked for me. The accepted answer covers almost everything needed. Recognizing this is a pretty niche example, but hopefully there may be some useful things in here that will save folks a few google searches.

For CUDA 8.0 in step 1 click “Legacy Releases” and select “CUDA Toolkit 8.0 GA 2”. Then Linux, x86_64, Ubuntu, 16.04, runfile (local).

I did not accept the packaged driver and instead used my previously installed 384.130 drivers for my GPU. More info on that here: Debian Wiki. Your mileage may vary, I cannot speak for cards other than a GT 720. This was the path I chose, I have no regrets (yet).

When the installation fails due to an inability to local in step 12 you will need to unpack the file but running it with the –tar mxvf flag. Then (as root) copy to /usr/lib/x86_64-linux-gnu/pearl-base:

./ --tar mxvf
sudo cp /usr/lib/x86_64-linux-gnu/perl-base

Now step 12 command should succeed.

Your Debian 9.0 comes with g++ version 6+, this won’t do. The compilation of vectorAdd in step 15 will fail. I followed this whitepaper: Installing Multiple Versions of GCC to install version 5.5.0. For 5.5.0 you will want this file


and unpack the tarball with this:

tar -xJf gcc-5.5.0.tar.xz

I needed to update some things (libraries and add 32-bit compilation) for this to work for me:

sudo apt-get install libgmp3-dev libmpfr-dev libmpc-dev
sudo dpkg --add-architecture i386
sudo apt-get update
sudo apt-get install build-essential gcc-multilib rpm libstdc++6:i386 libgcc1:i386 zlib1g:i386 libncurses5:i386

Now you can configure, make and install the compiler.

Remember to configure with the –prefix=/usr/local/gcc/5.5.0 flag

Now you can compile the vectorAdd example in step 15 with this:

make HOST_COMPILER=/usr/local/gcc/5.5.0/bin/g++

Or this:

export HOST_COMPILER=/usr/local/gcc/5.5.0/bin/g++

There is no need to modify the Makefile, it handles the compiler override correctly.

You should now have a working CUDA 8.0 installation on stretch.

Answered By: Ingo

Verifying install on Debian 9 Stretch & changing PATH & LD_LIBRARY_PATH

Einpoklum‘s answer above helped me install CUDA 10.0 on Debian 9 Stretch.

After successfully installing CUDA I could not verify the version, and troubleshot that it was because I needed to change the PATH & LD_LIBRARY_PATH permanently by editing the .bashrc file

CUDA Toolkit Documentation here

Answered By: Kelly