Skip to content

Instantly share code, notes, and snippets.

@nickovchinnikov
Forked from p-karanthaker/f35-nvidia-cuda.md
Created June 27, 2022 19:55
Show Gist options
  • Save nickovchinnikov/13b641b12dac636f726edac07554465f to your computer and use it in GitHub Desktop.
Save nickovchinnikov/13b641b12dac636f726edac07554465f to your computer and use it in GitHub Desktop.
Fedora 35 NVIDIA/CUDA Installation for TensorFlow

Fedora 35 NVIDIA/CUDA Installation for TensorFlow

These are the steps I took for the installation of the NVIDIA drivers and CUDA toolkit for use with TensorFlow on Fedora 35. I have documented them since I had a lot of difficulty getting it to work and couldn't boot to a graphical desktop a few times. These steps worked for me, hopefully they do for others.

Assumptions

I am running on a 64 bit system and used KDE Plasma with X11 so these instructions may differ for people using GNOME, Wayland and any other combinations.

Pre-requisites

  • If you have installed any NVIDIA drivers other than the akmod-nvidia drivers from the @rpmfusion-nonfree repo, remove them completely.
  • Remove any other NVIDIA/CUDA installations. Find them with sudo dnf list installed | egrep '(nvidia|cuda)'
  • If the nvidia-driver module is enabled, disable it - sudo dnf module disable nvidia-driver - this caused me issues when trying to install the akmod drivers

Installation

Install akmod-nvidia

It's available in the @rpmfusion-nonfree repo. Current docs on the Fedora Docs - Setup RPMFusion sudo dnf install akmod-nvidia

Install CUDA

I didn't need to do all the steps in the NVIDIA docs so I'm just documenting what I did. Please read through them in case you might need to do additional steps

  • Follow the Pre-Install Actions on the NVIDIA docs for Fedora. This will ensure you have the correct kernel-headers and kernel-devel packages.

From the Package Manager Installation on the NVIDIA docs for Fedora.

  • Add the CUDA repo - sudo dnf config-manager --add-repo https://developer.download.nvidia.com/compute/cuda/repos/${FEDORA_RELEASE}/x86_64/cuda-${FEDORA_RELEASE}.repo - FEDORA_RELEASE for me was fedora35
  • Install CUDA - sudo dnf install cuda

Install cuDNN

The cuDNN libraries do not exist in the CUDA repo (at the time of writing - for fedora35 at least). It does exist for rhel. I downloaded them as a tar and then installed manually.

  • Download the tar cuDNN - you'll need to sign up unfortunately and fill out a small survey. I got the Linux x86_64
  • Follow the Tar File Installation on the NVIDIA docs. Steps copied below in-case link becomes broken.
tar -xvf cudnn-linux-x86_64-8.x.x.x_cudaX.Y-archive.tar.xz

# Copy the following files into the CUDA toolkit directory.

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

Add evironment variables and edit PATH

Add the following to your shell profile. I use zsh so it went in the ~/.zshrc

CUDA_HOME=/usr/local/cuda-11.6/bin
export LD_LIBRARY_PATH=/usr/local/cuda-11.6/lib64
export PATH=$PATH:$CUDA_HOME

References

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment