Bash scripts to automate installation of NVIDIA proprietary driver

Ok, I finally got this working! Cannot believe how hard this was. So, installing the nvidia driver with the tutorial was only half the way. This is my first notebook with an integrated and a nvidia gpu. So the problem was that the i915 gpu was the default one and just used for everything. As I don’t have access to the bios, I couldn’t switch to discreet only.

So what I did. I added two more modules to blacklist

disable-nouveau.conf:

blacklist nouveau
blacklist nvidiafb
blacklist rivafb
options nouveau modeset=0

I added another file to modprobe.d

nvidia-drm.conf:

options nvidia_drm modeset=1

I added:

/etc/X11/xorg.conf.d/90-mhwd.conf

Section “Module”
Load “modesetting”
EndSection

Section “Device”
Identifier “nvidia”
Driver “nvidia”
BusID “PCI:1:0:0”
Option “AllowEmptyInitialConfiguration”
EndSection

Added /usr/local/share/optimus.desktop

[Desktop Entry]
Type=Application
Name=Optimus
Exec=sh -c “xrandr --setprovideroutputsource modesetting NVIDIA-0; xrandr --auto”
NoDisplay=true
X-GNOME-Autostart-Phase=DisplayServer

Then symlink

sudo ln -s /usr/local/share/optimus.desktop /usr/share/gdm/greeter/autostart/optimus.desktop
sudo ln -s /usr/local/share/optimus.desktop /etc/xdg/autostart/optimus.desktop

When the destination folders don’t exist, just create them.

Then reboot and cross fingers :wink:

All instructions beyond the nvidia driver tutorial are basically from here:

This is the result on a Thinkpad P72 with Quadro 5200:

glxinfo
name of display: :1
display: :1 screen: 0
direct rendering: Yes
server glx vendor string: NVIDIA Corporation
server glx version string: 1.4
.
.
.
OpenGL version string: 4.6.0 NVIDIA 430.14
OpenGL shading language version string: 4.60 NVIDIA
OpenGL context flags: (none)
OpenGL profile mask: (none)
OpenGL extensions:

Maybe this could be useful for similar setups.

Cheers

6 Likes