Setup Nvidia Drivers And NVIDIA Cuda Toolkit On Linux (PART-2)


A Complete Guide To Setup Nvidia Drivers And NVIDIA Cuda Toolkit On Fedora Linux



If you are struggling to setup NVIDIA drivers or NVIDIA CUDA environment in Linux and does not find a complete solution then this guide is for you. This Guide have two parts; first, Installing NVIDIA drivers and second, setting up NVIDIA CUDA toolkit. This guide is tested on Fedora 34 and may or may not work on other Linux distros.

This is the second part of the guide which is installing NVIDIA CUDA toolkit which requires NVIDIA drivers installed. If you don't have NVIDIA drivers installed already, then following the first part of this guide before continuing. You can verify your NVIDIA driver installation by running the below command.

nvidia-smi

The output should be similar to the given below if you have valid Nvidia drivers installed.


Preliminaries

Update your system by running the following commands and reboot.
NOTE: below command will update and install some dependencies for  your system and reboot it
.

sudo dnf update 
sudo dnf upgrade
dnf install gcc-c++ mesa-libGLU-devel libX11-devel libXi-devel libXmu-devel freeglut freeglut-devel
reboot


Step 1 ~ NVIDIA CUDA Toolkit Install Guide

Download and install the latest NVIDIA CUDA Toolkit from official website.
Go to the path where you have downloaded the file and run the bellow commands.

chmod +x cuda*.run
sudo sh cuda*.run --override

# Example
# sudo sh cuda_11.2.2_460.32.03_linux.run --override


Follow the installation prompts (Choose accept)


uncheckDriver and select Install




Add CUDA to system path variable

I am using zsh as my shell, so I add this to my '~/.zshrc'.  You can also put below lines in your '~/.bashrc' or ~/.profile'.

export PATH=/usr/local/cuda-11.2/bin${PATH:+:${PATH}}
export LD_LIBRARY_PATH=/usr/local/cuda-11.2/lib64${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}


Important: You need to copy CUDNN files to '/usr/local/cuda-11.2/'. You can download the required files from NVIDIA official website.


You can verify your NVIDIA CUDA Toolkit installation by running below command

nvcc --version

The output should be similar to the given below if everything have been done smoothly.



To uninstall the NVIDIA CUDA Toolkit, run  below Command

/usr/local/cuda-*/bin/cuda-uninstaller

# Example
# /usr/local/cuda-11.2/bin/cuda-uninstaller


You should have successfully installed NVIDIA drivers and NVIDIA CUDA Toolkit.


Download Section:

Leave a comment below if you have any question or suggestions.

Happy Posting! See you in the next one.


Buy me a coffee!    or    Show your support!



Related Posts


Setup Pycharm IDE With Global Package Manager

Easy To Follow And Step-By-Step Guide To Setup Pycharm IDE With Global Packages Manager


By Yasir Hussain | Posted 5 months ago

Setup Pycharm IDE In Linux

Easy To Follow And Step-By-Step Guide To Setup JetBraine Pycharm IDE In Your Linux Distro


By Yasir Hussain | Posted 5 months ago

Setup IntelliJ IDE In Linux

Easy To Follow And Step-By-Step Guide To Setup JetBrains IntelliJ IDE In Your Linux Distro


By Yasir Hussain | Posted 5 months ago