How to install & configure nvidia driver on arch linux

Nvidia is a graphics processing chip manufacturer that currently generates most of its revenue from the sales of graphics processing units (GPUs), which are used for competitive gaming, professional visualization, and cryptocurrency mining.

1. Install nvidia driver using pacman command

“`sudo pacman -S nvidia“`

Note: add pacman hook to compile module on kernel upgrades

/etc/pacman.d/hooks/nvidia.hook
[Trigger]
Operation=Install
Operation=Upgrade
Operation=Remove
Type=Package
Target=nvidia
Target=linux
# Change the linux part above and in the Exec line if a different kernel is used

[Action]
Description=Update Nvidia module in initcpio
Depends=mkinitcpio
When=PostTransaction
NeedsTargets
Exec=/bin/sh -c 'while read -r trg; do case $trg in linux) exit 0; esac; done; /usr/bin/mkinitcpio -P'

2. Blacklist nouveau driver

“`sudo bash -c “echo blacklist nouveau > /etc/modprobe.d/blacklist-nvidia-nouveau.conf”“`

3. Add graphics card configuration in Xorg server

/etc/X11/xorg.conf.d/20-nvidia.conf

Section "OutputClass"
Identifier "intel"
MatchDriver "i915"
Driver "modesetting"
EndSection

Section "OutputClass"
Identifier "nvidia"
MatchDriver "nvidia-drm"
Driver "nvidia"
Option "AllowEmptyInitialConfiguration"
Option "PrimaryGPU" "yes"
ModulePath "/usr/lib/nvidia/xorg"
ModulePath "/usr/lib/xorg/modules"
EndSection

4. Load nvidia modules on boot – update firmware

/etc/mkinitcpio.conf

“`MODULES=(nvidia nvidia_modeset nvidia_uvm nvidia_drm)“`

sudo mkinitcpio -P linux

5. Finally, update ~/.xinitrc

use this command to list providers and update in xinitrc file

“`xrandr –listproviders“`

~/.xinitrc

xrandr --setprovideroutputsource modesetting NVIDIA-0
xrandr --auto
exec i3 &>> "/var/log/i3.log"

Test the GPU processes now

Using nvidia-smi

Using nvtop

5 thoughts on “How to install & configure nvidia driver on arch linux

  1. Hello! Still can’t make it work. Should I create the xinitrc for the user or root? i3 throws a permission denied. Confused as hell :S

    1. yes,
      you should.
      my .xinitrc looks like this.

      #!/bin/sh

      userresources=$HOME/.Xresources
      usermodmap=$HOME/.Xmodmap
      sysresources=/etc/X11/xinit/.Xresources
      sysmodmap=/etc/X11/xinit/.Xmodmap

      # merge in defaults and keymaps

      if [ -f $sysresources ]; then
      xrdb -merge $sysresources
      fi

      if [ -f $sysmodmap ]; then
      xmodmap $sysmodmap
      fi

      if [ -f “$userresources” ]; then
      xrdb -merge “$userresources”
      fi

      if [ -f “$usermodmap” ]; then
      xmodmap “$usermodmap”
      fi

      # start some nice programs

      if [ -d /etc/X11/xinit/xinitrc.d ] ; then
      for f in /etc/X11/xinit/xinitrc.d/?*.sh ; do
      [ -x “$f” ] && . “$f”
      done
      unset f
      fi

      # xscreensaver &
      # xrandr –listproviders
      xrandr –setprovideroutputsource modesetting NVIDIA-0
      #xrandr –setprovideroutputsource modesetting NVIDIA-G0
      #xrandr –setprovideroutputsource modesetting nouveau
      xrandr –auto
      exec i3 &>> “/var/log/i3.log” # replace with your own display manager

        1. lightdm u create a symlink by using the `”systemctl enable lightdm”` command
          and it will automatically log u in, if u want to specifically control how x-starts, then check your zprofile. (I use Zsh)

  2. Bruh, thanks, i literally spend the whole day trying to fix, this problem, and i couldnt install additional ram, i found out is because of neoveu

Leave a Reply

Your email address will not be published. Required fields are marked *