nVidia CUDA on Linux (Fedora 15)

A step-by-step walk-through making the CUDA SDK work on Linux.
3 min read

I recently updated my desktop with a new graphic card from nVidia - a pretty low-end GT440.

It’s actually my first nVidia card. I owned three ATI Radeon cards (Sapphire 9550, 9600Pro and HD2600XT) before. The main reason for this was, that I needed CUDA enabled card in order to be able to work on my school project (I study computer graphics). On top of that, Gnome 3 has some issues with ATI drivers and the HD2600XT is like 5 years old today. Anyway, I recently installed the nVidia CUDA SDK on Fedora 15 and I made a little howto along the way.

Installing gcc

One of the biggest issues in with CUDA is that it officially supports only gcc of version 4.4 and earlier. That’s a bummer, especially on Fedora, where there is gcc-4.6 by default and you need to compile the older version yourself. I posted series of steps to compile gcc from sources in a separate article Multiple Versions of gcc on Fedora 15.


There is something called Developer Drivers for Linux available from the nVidia website. I don’t know what it is or how is it different from the original drivers, but I couldn’t make them work. The installation kept dying with some error with kernel headers.

Good news is, that you don’t need them. At least I was able to compile and run the CUDA SDK without installing these only with the standard nVidia proprietary driver (version 285.05.09). If you’re running them, you’re fine. In case you have the noveau open-source drivers you need to get rid of them and install the nVidia proprietary driver.

There is one little thing you need to do if you chose not to install the developer drivers: make a symlink for libcuda.so like this

su cd /usr/lib
ln -s nvidia/libcuda.so libcuda.so

CUDA Toolkit

This is pretty straight-forward. Download and run shell script from the nVidia download page. Choose what’s closest to your distro. In this case it’s Fedora 13. Fedora 15 is officially unsupported due to the lack of old gcc. But we have sorted this earlier, so it’s fine to use the F13 pack.

wget http://www.nvidia.com/object/thankyou.html?url=/compute/cuda/4_0/toolkit/cudatoolkit_4.0.17_linux_32_fedora13.run
sudo sh cudatoolkit_4.0.17_linux_32_fedora13.run

In case you’re prompted with question where to install the toolkit, just hit to keep the defaults.

GPU Computing SDK

Installing the SDK is as easy as the toolkit. Download and run the script from nVidia homepage. This time you won’t need root permissions, because it will install into your home folder.

Setting System Path

The tricky part is here, now you need to make sure all  the libraries and tools are present in the correct environment variables. Edit your ~/.bashrc file and add the following:

export PATH="$PATH:/usr/local/cuda/bin"
export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:/usr/local/cuda/lib"

Reopen your shell and you should be able to run the nvidia C compiler. Make sure by trying this

nvcc --version

The last step is trying to compile all the examples in the SDK. Change to that directory and simply run make.

cd /NVIDIA_GPU_Computing_SDK make

Everything should be working. There will be a lot of warnings during the compilation, but we just have to ignore that…