Versión en español de esta publicación.
This tutorial explains how to install CUDA 7.0 Production Release in a Debian Wheezy system, the first thing we have to do is to download the graphics driver from Nvidia website and select the current model of the graphics card we have, in my case I have a server with 2 Nvidia cards the first one is a GeForce GTX660 and the second one is a GeForce GTX650, if you’re not sure of which driver version you should install, you can check the driver versions and models in the following link
http://www.nvidia.com.mx/Download/index.aspx?lang=en-us
The required driver version that supports the new CUDA 7.0 features is 346 or above, please make sure to download the latest version of your card driver
Also we need to download the CUDA toolkit 7.0 from the following link
https://developer.nvidia.com/cuda-toolkit
The installer file of the toolkit we need to download is the Linux RUN file for Ubuntu, the file name is: cuda_7.0.28_linux.run and the direct link is the following
http://developer.download.nvidia.com/compute/cuda/7_0/Prod/local_installers/cuda_7.0.28_linux.run
Now we need to verify that we have a CUDA capable GPU by running the following command
cuda7_install.sh
# verify we have a cuda capable gpu lspci | grep -i nvidia
In my case the output is something like this
cuda7_install.sh
# lscpi output 03:00.0 VGA compatible controller: NVIDIA Corporation Device 11c0 (rev a1) 03:00.1 Audio device: NVIDIA Corporation Device 0e0b (rev a1) 04:00.0 VGA compatible controller: NVIDIA Corporation Device 0fc6 (rev a1) 04:00.1 Audio device: NVIDIA Corporation Device 0e1b (rev a1)
If you don’t get any output you should verify that your hardware is correctly installed, next we proceed to verify our Linux version by running the following command
cuda7_install.sh
# Linux version uname -m && cat /etc/*release
For this post I’m using a Debian Wheezy installation so you should see something like this
cuda7_install.sh
# version output x86_64 PRETTY_NAME="Debian GNU/Linux 7 (wheezy)" NAME="Debian GNU/Linux" VERSION_ID="7" VERSION="7 (wheezy)" ID=debian ANSI_COLOR="1;31" HOME_URL="http://www.debian.org/" SUPPORT_URL="http://www.debian.org/support/" BUG_REPORT_URL="http://bugs.debian.org/"
Now we need to verify that we have a valid GCC compiler, this is required in order to install the Nvidia driver, we check it by running the following command
cuda7_install.sh
# verify gcc version gcc --version
And you should see an output like this
cuda7_install.sh
# gcc output gcc (Debian 4.7.2-5) 4.7.2 Copyright (C) 2012 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
If you don’t have a valid GCC compiler installed please install it by running the following command
cuda7_install.sh
# gcc install sudo apt-get install build-essential
Before we proceed with the actual installation process we need to uninstall any version of CUDA we had installed previously, if this is the first time you install CUDA please skip this step, we uninstall previous installations by running the following command
cuda7_install.sh
# cuda uninstall sudo /usr/local/cuda-X.Y/bin/uninstall_cuda_X.Y.pl
Where X and Y is the cuda version
If we are upgrading the Nvidia driver we don’t have to do anything just because the installer itself removes old driver versions
If we want to uninstall the CUDA driver just run the following command
cuda7_install.sh
# cuda driver uninstall sudo /usr/bin/nvidia-uninstall
Once we have completed the steps above and have downloaded the files needed for the installation we proceed to disable the nouveau driver which is the default driver for Debian, we do that by creating a new file:
cuda7_install.sh
# edit debian driver configuration file vim /etc/modprobe.d/disable-nouveau.conf
And add the following content to it
cuda7_install.sh
# blacklist defualt driver blacklist nouveau options nouveau modeset=0
Note: to verify that we have the nouveau driver running, just run the following command, if it outputs something it means that we actually have a nouveau driver running
cuda7_install.sh
# verify noveau lsmod | grep nouveau
After having the file for blocking the default driver in place, we proceed to restart the machine in default mode,
Once restarted we are going to note that the screen resolution got at a lower level and that means that the default driver was not loaded, then we need to get some header files from our repository to build the Nvidia driver, we do this by executing the following command
cuda7_install.sh
# dependencies sudo apt-get install linux-headers-$(uname -r)
After installing this files we proceed to remove the nouveau driver completely from our system by executing the following command
cuda7_install.sh
# remove the nouveau driver completly apt-get remove --purge xserver-xorg-video-nouveau
After the removal of the driver has happened we need to restart our system in recovery mode, once restarted in recovery mode and having the nice console interface we proceed with the driver installation process, first we need to know which version of the compiler was used to compile the current system kernel, this because the system needs to compile the Nvidia driver, if we don’t know which version was used and which kernel we have, we can find that out by running the following command
cuda7_install.sh
# find curr gcc version cat /proc/version
And we get something like this
cuda7_install.sh
# version output Linux version 3.2.0-4-amd64 (debian-kernel@lists.debian.org) (gcc version 4.6.3 (Debian 4.6.3-14) ) #1 SMP Debian 3.2.54-2
Once we know the correct compiler version, we need to set it up with an export like this
cuda7_install.sh
# set gcc version export CC=gcc-4.6
Now we can proceed with the driver installation, we navigate to our download path and execute the driver
cuda7_install.sh
# execute driver install sudo sh NVIDIA-Linux-x86_64-346.47.run
Once the installation is finished we proceed to reboot the machine and we’re going to note that we have a nice screen resolution and our new Nvidia drivers installed, next we proceed with the toolkit installation like this.
cuda7_install.sh
# execute toolkit install sudo sh cuda_7.0.28_linux.run
When prompted we need to select not to install the Nvidia driver since we already installed it, and choose the default path for the samples (recommended)
The last thing to do is to compile the samples and run them, to do this we navigate to the samples directory that we choose and just execute a make command
And that’s it!
Here are some useful links related to CUDA 7.0
The CUDA getting started manual which covers in deep installation instructions
http://developer.download.nvidia.com/compute/cuda/7_0/Prod/doc/CUDA_Getting_Started_Linux.pdf
The CUDA downloads page
https://developer.nvidia.com/cuda-downloads
The Nvidia Driver downloads page
http://www.nvidia.com.mx/Download/index.aspx?lang=en-us
A couple of nice blog posts of the CUDA 7.0 features
http://devblogs.nvidia.com/parallelforall/power-cpp11-cuda-7/
http://devblogs.nvidia.com/parallelforall/cuda-7-release-candidate-feature-overview/
Have Fun! 🙂
-Yohan