Skip to content

Instantly share code, notes, and snippets.

@Mohit-Pala
Created May 21, 2024 12:49
Show Gist options
  • Select an option

  • Save Mohit-Pala/ee996094db6f2da04328e5eb74734307 to your computer and use it in GitHub Desktop.

Select an option

Save Mohit-Pala/ee996094db6f2da04328e5eb74734307 to your computer and use it in GitHub Desktop.
Simple guide to install nvidia drivers and cuda on arch linux

Install proprietary nvidia drivers on Arch Linux

This guide is only for Maxwell and newer cards

Simple guide to install nvidia drivers and cuda on arch linux. Please read the wiki before following this guide. I will be using the linux-zen kernel for this guide but this guide should work for the other kernels in the arch repo as well.

Update system and enable multilib before starting

sudo nano /etc/pacman.conf

Feel free to use vim, gedit or any other text editor. Scroll down until you find the words "multilib" and uncomment the following lines (remove the # sign)

[multilib]
Include = /etc/pacman.d/mirrorlist

Update the system using pacman to sync the multilib repo and to make sure you have the latest kernel

sudo pacman -Syu

Installing kernel headers

To proceed you will need the kernel headers if you are not using the default "Linux" kernel. The following table shows which package you will need to install.

Kernel Name Kernel Header Name
linux linux-headers
linux-zen linux-zen-headers
linux-lts linux-lts-headers

If you have installed a kernel from the AUR check to see if they provide the headers. For example linux-xanmod will require the linux-xanmod-headers package to provide headers

Install kernel headers using pacman or an AUR helper

sudo pacman -S linux-zen-headers dkms

Installing Nvidia drivers

Make sure your card is maxwell or newer, run the following to check your card model

lspci -k | grep -A 2 -E "(VGA|3D)"

My output:

01:00.0 VGA compatible controller: NVIDIA Corporation AD107M [GeForce RTX 4060 Max-Q / Mobile] (rev a1)

Install nvidia-dkms, nvidia-utils and lib32-nvidia-utils packages

sudo pacman -S nvidia-dkms nvidia-utils lib32-nvidia-utils

open the file /etc/mkinitcpio.conf and make delete the word 'kms' from the line which contains Hooks()

HOOKS=(base udev autodetect microcode modconf keyboard keymap consolefont block filesystems fsck)
# make sure this line does not contain the word kms

DRM Mode Setting

Open grub config file and add the following statements after GRUB_CMDLINE_LINUX_DEFAULT

sudo nano /etc/default/grub

GRUB_CMDLINE_LINUX_DEFAULT="loglevel=3 splash nvidia-drm.modeset=1"

Recreate grub

sudo grub-mkconfig -o /boot/grub/grub.cfg

Early Loading

Open your mkinitcpio conf and add the following to the Modules line

sudo nano /etc/mkinitcpio.conf

MODULES=(nvidia nvidia_modeset nvidia_uvm nvidia_drm)

recreate initramfs

sudo mkinitcpio -P

Congratulations

You have completed all steps to install proprietary nvidia drivers. You can reboot your system now or move onto the next steps which explain how to install CUDA and other nvidia tools

X settings and Overclocking and PRIME

nvidia-settings package can be used to configure the GPU

sudo pacman -S nvidia-settings

Overclocking

In an xorg session you can overclock your nvidia GPU using Green With Envy which is available through flathub and the AUR

AUR

paru -S gwe

Flatpak

sudo pacman -S flathub

Discover store -> search -> green with envy

PRIME

install nvidia-prime and launch applications using prime-run

sudo pacman -S nvidia-prime

prime-run vkcube

CUDA

Install the above proprietary drivers then follow the instructions

Install opencl-nvidia and cuda

sudo pacman -S opencl-nvidia cuda

Install cuda-tools for nvvp and nsight

sudo pacman -S cuda-tools

install cudnn for NVIDIA CUDA Deep Neural Network library

sudo pacman -S cudnn
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment