Nvidia (9.0) installation for TensorFlow & PyTorch on Fedora 27
Just use Negativo’s Repo…
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.
I had tried this method before (on previous Fedoras), but the choices of paths had
left me unconvinced (particularly since during the ‘teething’ phase of getting the
installation working, error messages can come from all sorts of sources/reasons).
Here’s a quick run-down of what has worked for me :
Clean out previous installations
Check that you’ve got a GPU
should result in a line that mentions your VGA adapter.
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
for “Download and install cuDNN” shows that TensorFlow v1.4 (the current stable release) expects CUDA toolkit v8.0,
which is not good, because Negativo packing supplies CUDA v9.0 (there’s a similar issue for cuDNN, for which
Negativo supplies v7.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 what 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.