Wednesday, December 18, 2013

Setting up CUDA on Fedora 20

Installing Nvidia's CUDA on Fedora is pretty simple, but the official documentation (warning, PDF link) falls a little short if you are using the Nvidia drivers packaged by RPM Fusion. If you are using the officially packaged Nvidia drivers, just follow the official docs, otherwise follow along after the break.


First, install the CUDA Yum repository, ignoring the fact Nvidia claims it's for Fedora 19:

# rpm -ivh http://developer.download.nvidia.com/compute/cuda/repos/fedora19/x86_64/cuda-repo-fedora19-6.0-37.x86_64.rpm

This will add a 'cuda.repo' file in '/etc/yum.repos.d'.

Now, we want to download and install the CUDA packages:

# yum install cuda cuda-cross

This will download and install CUDA (as well as remind you endlessly about Nvidia's EULA).

At this point, CUDA should be installed and ready to go. Switch back to a user account (unless you did all the above with sudo, then you never left). Nvidia graciously provides some samples we can use to ensure CUDA is working. Install them to your home directory:

$ /usr/local/cuda-6.0/bin/cuda-install-samples-6.0.sh ~

You should now have a 'NVIDIA_CUDA-6.0_Samples' in your home directory. Navigate there, and compile them (as per the Nvidia guide, set the necessary environment variables first, I'm assuming a 64 bit system here):

$ cd ~/NVIDIA_CUDA-6.0_Samples
$ export PATH=/usr/local/cuda-6.0/bin:$PATH
$ export LD_LIBRARY_PATH=/usr/local/cuda-6.0/lib64:$LD_LIBRARY_PATH
$ make
 
The will take quite a while, after which each subdirectory should contain one ore more sample CUDA apps. Run one to make sure it works, 'fluidsGL' is my favorite:

$ 5_Simulations/fluidsGL/fluidsGL

The result should look something like this:


You are good to use CUDA at this point.

Update 2014-6-10:
With the release of CUDA 6, this has been updated. I didn't have much luck doing a straight upgrade, I wound up uninstalling CUDA 5.5, and then doing the updated steps above. The remove command is listed below, make doubly sure you aren't about to accidentally remove something important before running the uninstall. Also make sure you have updated your Nvidia driver to the latest in RPM Fusion. Other than that, the install should proceed much smoother than it did with CUDA 5.5. If CUDA complains about not being able to find a compatible device, try rebooting.

# yum remove cuda-*

1 comment:

  1. Best damn tutorial ever, hours and hours and hours of RPM fiddling saved with a single blog post. thanks man!

    ReplyDelete