## Now tf-nightly & PyTorch work on cuda 10 …

Ever since Nvidia totally screwed up the gcc versioning/ABI on Fedora 24, I decided to take the easy option and use someone else’s pre-packaged Nvidia installation. My packager of choice has been Negativo.

However, around Fedora 26/27 the Negativo repo was quickly updated to cuda-9.1 whereas it seems that the TensorFlow team decided to skip 9.1 and move to 9.2 directly, but not go for 10.0 when all Fedora, the repos and PyTorch did.

The situation has now become more unified, assuming you’re willing to take a risk on installing the tensorflow nightly builds (1.13.xxx), which have been cuda 10.0 ready since (apparently) mid-Dec-2018.

Here’s a quick run-down of what has worked for me (having had to install Nvidia/cuda from the Nvidia website for Fedora recently, or compiling tensorflow from scratch, which are both painful )…

( Happy to be back using a ‘proper’ repo, and pip install for the frameworks again. )

### Check that you’ve got a GPU

Running :

should result in a line that mentions your VGA adapter.

### Add the Negativo Nvidia Repo

The negativo Nvidia repo should now be added :

And then install the nvidia driver, and the necessary libraries for cuda operations.

Note that if you want X11 to run on the graphics card, you’ll obviously need a monitor attached. However, since I didn’t attach a monitor to the machine while doing this, it’s not proven that the video card ends up capable of doing anything but cuda operations :: But that’s fine with me, because this is a machine that won’t ever have a monitor attached to it (much to the disappointment of the gamers in the office).

The following will each pull in a load more dependencies (the Negativo repo is intentionally modular / fragmented) :

In my case, I also added an intel driver for the internal on-board video subsystem (just so that X11 might be tempted to run if there’s a monitor plugged in - but check out the companion post on how to get the X11 configuration working properly if you do want to add a monitor, and also enable the Nvidia card for CUDA without it having a display attached) :

Now after rebooting :

The key thing here are the references to nvidia and nvidia_uvm.

If you’ve got references to nouveau appearing in lsmod, something didn’t work correctly.

### Install TensorFlow for the GPU

Looking within the TensorFlow installation instructions and it’s linked helper page, shows that TensorFlow v1.12 (the current stable release) expects CUDA toolkit v9.0, which is not good, because Negativo packing supplies CUDA v10.0.

To counteract this, install the (now available) TensorFlow ‘nightly’ build, which is apparently built to be ready for the latest versions (this assumes python 3.x, which should be the obvious choice by now):

### Test TensorFlow with the GPU

The following can be executed (the second line onwards will be within the Python REPL) :

This is the kind of message that will appear if the installation DIDN’T WORK :

### Fixing the /dev/nvidia0 problem

This should not happen if you’re running on the Nvidia card as a display adapter, or have installed the nvidia-modprobe package above. If there’s still a problem, have a look at the solution previously found.

### When it finally works…

Then the python REPL code :

Produces the following happy messages :

NB: tensorflow has to be compiled from source to work with compute capability of <3.5. Unfortunately, my GTX 760 has a compute capability of 3.0. There are some indications that installing from source would help - but that is untested as-yet.

### Install PyTorch for the GPU

Looking within the PyTorch installation instructions we see that there’s an option for CUDA toolkit v10.0, which is good, and Python 3.6 is supported (also good).

Then finally test it with the same Hello World calculation as we did for TensorFlow :

NB: PyTorch has to be compiled from source to work with compute capability of <5.5. There are some claims that installing from source would help - but that is untested as-yet.

All done.