First determine what driver is installed. Below we can see that we are running the “nouveau” driver and not the Nvidia proprietary driver.
$ sudo lspci -n -n -k | grep -A 2 -e VGA -e 3D
01:00.0 VGA compatible controller [0300]: NVIDIA Corporation GA106 [GeForce RTX 3060 Lite Hash Rate] [10de:2504] (rev a1)
Subsystem: PNY Device [196e:138f]
Kernel driver in use: nouveau
Add rpm fusion repos.
$ sudo dnf install https://mirrors.rpmfusion.org/free/fedora/rpmfusion-free-release-$(rpm -E %fedora).noarch.rpm https://mirrors.rpmfusion.org/nonfree/fedora/rpmfusion-nonfree-release-$(rpm -E %fedora).noarch.rpm
Dnf update.
$ sudo dnf update -y
Install kernel-devel which provides kernel headers and makefiles required to build kernel modules.
$ sudo dnf -y install kernel-devel
Install akmod-nividia, which checks if there are any missing kernel mods at boot time and will if so, will build them.
$ sudo dnf -y install akmod-nvidia
Now install the CUDA driver for xorg-x11-drv-nvidia.
$ sudo dnf -y install xorg-x11-drv-nvidia-cuda
Enable/start Nvidia nvidia-persistenced.service.
sudo systemctl enable --now nvidia-persistenced.service
Reboot.
Now we check to make sure that the driver is loaded.
$ sudo lspci -n -n -k | grep -A 2 -e VGA -e 3D [sudo] password for cpaquin: 01:00.0 VGA compatible controller [0300]: NVIDIA Corporation GA106 [GeForce RTX 3060 Lite Hash Rate] [10de:2504] (rev a1) Subsystem: PNY Device [196e:138f] Kernel driver in use: nvidia
Run “nvidia-smi” to show the exact driver revision. Below we have 565.77. And this driver is compatible with CUDA Version: 12.7.

Nvidia Cuda Toolkit Install
We now need to install the nvidia-cuda-toolkit. We will get this directly from nvidia. According to the driver/toolkit version matrix found here, we should install Cuda Toolkit 12.6.
First install the following pre-req. Nvcc will not compile on gcc14 which is default for Fedora 40.
# sudo dnf install gcc13-c++ -y
Pull down the installer
wget https://developer.download.nvidia.com/compute/cuda/12.6.2/local_installers/cuda_12.6.2_560.35.03_linux.run
Make the file executable
$ sudo chmod +x cuda_12.6.2_560.35.03_linux.run
Now install. Since we already have drivers installed, make sure that you uncheck all install options except for the toolkit itself.
sudo ./cuda_12.6.2_560.35.03_linux.run
Add the following to your .bashrc. And if you intend to run/install anything as root, you may want to add it to root’s .bashrc as well.
export PATH=/usr/local/cuda-12.6/bin:$PATH
Next add “/usr/local/cuda-12.6/lib64” to “/etc/ld.so.conf” and run “ldconfig” as root. See example below
# cat /etc/ld.so.conf
include ld.so.conf.d/*.conf
/usr/local/cuda-12.6/lib64
Now run ldconfig
# ldconfig
Now test nvcc as shown below.
$ nvcc --version
nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2024 NVIDIA Corporation
Built on Thu_Sep_12_02:18:05_PDT_2024
Cuda compilation tools, release 12.6, V12.6.77
Build cuda_12.6.r12.6/compiler.34841621_0
Resources
- https://www.reddit.com/r/Fedora/comments/1gpp5a4/how_to_install_nvcc_on_fedora_41/
- https://rpmfusion.org/Howto/NVIDIA#Akmods
- https://packages.fedoraproject.org/pkgs/kernel/kernel-devel/
- https://rpmfusion.org/Configuration
- https://forums.developer.nvidia.com/t/cuda-toolkit-support-for-fedora-40/308193/2
- https://forums.developer.nvidia.com/t/cuda-toolkit-installation-problems-on-fedora-41-forty-one/317186/2