Machine Learning

Installing CUDA and cuDNN on openSUSE Tumbleweed

SuSE Linux 6.2, released 20 years ago, was my first experience with a linux-based operating system. Even though I soon thereafter switched to Gentoo and later Ubuntu, I have always retained a soft spot for SUSE — so when I recently built a new data science machine I decided to give openSUSE Tumbleweed a try. Tumbleweed is a rolling release distribution, providing frequent updates of all packages without making you update the entire distribution in point release intervals.

Tumbleweed’s rolling release makes it difficult to rely on a particular version of a package (say of gcc) on a user’s computer. It is therefore unsupported by a handful of important proprietary packages, most notably Nvidia’s CUDA platform, which has become a requirement for the completion of demanding machine learning tasks. I will discuss here how to install CUDA on Tumbleweed even though it’s not supported — and so far I have been using it without problems.

This post assumes that you own at least one somewhat recent Nvidia graphics card and that you have installed the proprietary Nvidia drivers on your Tumbleweed machine as explained here.

Go ahead and download the CUDA runfile (not the rpm) for the most recent release of openSUSE Leap (the point release cousin of Tumbleweed). At the time of this blog post I downloaded the runfile for Leap 15.0. Executing the runfile will let you install the CUDA toolkit without installing the driver, an option that the rpm does not provide. When you execute the runfile, a few checks are run to make sure that you are using an openSUSE Leap system with a specific version of gcc (which you are not). Our hope is that CUDA will work anyways (which as of August 2019 is true); therefore we need to circumvent the checks via the –override flag, i.e.

./cuda_10.1.243_418.87.00_linux.run --override

After accepting the license agreement you will be able to deselect installation of the driver — make sure you do so.

Once you have selected “Install” you should have a functional installation of the CUDA toolkit in /usr/local/cuda. Upon exiting, the runfile will print information on how to modify your system so that other program on your machine can find the toolkit. Make sure you follow these instructions. For me, this meant to add the following line to /etc/ld.so.conf.

/usr/local/cuda-10.1/lib64

Then, call ldconfig,

sudo ldconfig

Additionally, I had to modify the PATH variable, which I did by appending the following line to .bashrc.

PATH=/usr/local/cuda-10.1/bin:$PATH

Lastly, you will probably also want to install NVIDIA cuDNN, the CUDA deep neural network library. Download a tarball of the library from here. Extract it somewhere (for example into your home directory) and then copy the extracted files into their corresponding locations in /usr/local/cuda, e.g. (see this very useful discussion)

sudo cp -P include/cudnn.h /usr/local/cuda/include
sudo cp -P lib64/libcudnn* /usr/local/cuda/lib64
sudo chmod a+r /usr/local/cuda/lib64/libcudnn*

That’s it! CUDA and cuDNN should now just work when you specify cuda as the execution target for Theano or Tensorflow!