How to install NVIDIA CUDA 6 (and compile all the samples) in Debian Testing x86_64

Debian is not among the GNU/Linux distribution officially supported by the NVIDIA CUDA SDK 6.0 installer. The installation is nevertheless possible and quite straightforward. However, compiling the samples requires a bit of code hacking. Here is how I did it:

1.- First, I downloaded the latest drivers from here and installed them using the standard procedure. This requires a reboot. The Debian developers have just removed the nvidia-driver from the Testing repositories. However, I decided to remove any traces with “aptitude purge nvidia*” prior to the installation of the proprietary blob.

2.- Next, I downloaded the CUDA 6.0 Ubuntu 13.04 standalone installer from here and installed it as root. I installed the whole thing with the exception of the driver. Even if gcc-4.8 is not officially supported by this version of the CUDA SDK, it seems to work fine. Gcc-4.9 is already on the repos but I have not tested it. Anyway, one can use “update-alternatives –config gcc” (g++/cpp) in order to choose the default version of the compiler. 4.6 is also in the repos and it is officially supported. If you choose an unsupported compiler, just remember to run the installer with the “-override compiler” flag.

3.- Now you need to make your system aware of the location of the CUDA binaries and libraries. This can be done globally for all users by appending /usr/local/cuda-6.0/bin to the path in /etc/profile, creating an /etc/ file containing the line /usr/local/cuda-6.0/lib64 and then running ldconfig as root.  If you do not have root access you can configure it for your current user by adding the following lines to your .bashrc file:

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

Followed by “source ~/.bashrc” in case that you wish your current shell to be aware of the newly added paths.

4.- Now, if you want to compile all the samples (optional), you will first need the following libraries (including the the developer packages) installed: libGLU, libX11, libXi, libXmu, libglut, libGLEW (in addition to libGL, which is provided by the driver itself).

5.- The problem with the samples is that the make files do not know where to find all that stuff in Debian, even if it is installed. So here comes the hack. Change directory to NVIDIA_CUDA-6.0_Samples (if you installed it as root you may need to change permissions recursively so that your current user can write into it).

The first thing we have to do is making the Makefiles (there are many) aware of the actual location of the required libraries in a current Debian x86_64 system (it goes for /usr/lib64, but that location has been superseded by /usr/lib):

find . -type f -print0 | xargs -0 sed -i ‘s#CUDA_SEARCH_PATH += /usr/lib64#CUDA_SEARCH_PATH += /usr/lib#g’

Next, we make the make files understand that Debian stores most of its libraries in the same locations as its scion Ubuntu:

find . -type f -print0 | xargs -0 sed -i ‘s#ubuntu#debian#g’

6.- Now we run make. If everything was carefully done, all programs should compile now (but not all the tests will pass, this depends on the capabilities of your GPUs). If you see warning messages about missing libraries just install what you need and try again.


Comments are closed.