-
As usual, please update your system before doing anything.
sudo apt update sudo apt full-upgrade
-
First of all, download the appropriate driver for your chipset: https://www.nvidia.com/Download/index.aspx
-
To be able to install your nvidia driver you have to remove your previous video driver with this code in a terminal window:
sudo nvidia-uninstall sudo apt remove --purge nvidia* -y sudo apt remove --purge libnvidia* -y sudo apt autoremove --purge -y sudo apt autoclean -y
-
After you finish with this one, you should also blacklist some drivers by editing this file with either:
/etc/modprobe.d/blacklist-nvidia-nouveau.conf
. During a new installation, this file should not exist. You just have to create it:touch /etc/modprobe.d/blacklist-nvidia-nouveau.conf
Add these lines at the end:
blacklist vga16fb blacklist rivafb blacklist rivatv blacklist nvidiafb blacklist nouveau blacklist lbm-nouveau options nouveau modeset=0 alias nouveau off alias lbm-nouveau off
-
And you can also disable the Kernel Nouveau by typing these lines in a terminal window:
echo options nouveau modeset=0 | sudo tee -a /etc/modprobe.d/nouveau-kms.conf
and after that regenerate the kernel :
sudo update-initramfs -u
-
Reboot your computer.
-
When you are on the login prompt, press CTRL + ALT + F1 to exit to the terminal console. Login with your username and password.
-
Go to the directory where you saved your nvidia driver using the command cd in the terminal console. To stop your display manager or the X server, you can type in the console this code:
sudo service lightdm stop
If you are not using lightdm as your default display manager (DM), replace lightdm with your default display manager, which can be either kdm or gdm or whatever your display manager is.
-
Enter in runlevel 3 :
sudo init 3
-
Install required dependencies not installed by the script because pre-install doesn't work and install some other to avoid posible errors when running script:
sudo apt install pkg-config libglvnd-core-dev libglvnd-dev libglvnd0 dkms fakeroot build-essential linux-headers-generic -y
-
And now you can finally install the nvidia driver using a code similar to this one:
chmod +x NVIDIA-Linux-x86_64-455.28.run sudo ./NVIDIA-Linux-x86_64-455.28.run --dkms
Because the Nvidia driver doesn't work perfectly, I recommend you to disable it when you don't need it. It will also save a little bit of battery. To do this, we add some simple scripts:
sudo apt install nvidia-prime
# Create simple script for launching programs on the NVIDIA GPU
echo '__NV_PRIME_RENDER_OFFLOAD=1 __GLX_VENDOR_LIBRARY_NAME="nvidia" __VK_LAYER_NV_optimus="NVIDIA_only" exec "$@"' >> /usr/local/bin/prime
sudo chmod +x /usr/local/bin/prime
# Create xorg.conf.d directory (If it doesn't already exist) and copy PRIME configuration file
mkdir -p /etc/X11/xorg.conf.d/
sudo wget https://raw.githubusercontent.com/MrZyr0/dell-xps-9570-ubuntu-respin/master/10-prime-offload.conf -O /etc/X11/xorg.conf.d/10-prime-offload.conf
# Enable modesetting on the NVIDIA Driver (Enables use of offloading and PRIME Sync)
sudo echo "options nvidia-drm modeset=1" >> /etc/modprobe.d/nvidia-drm.conf
You can now switch from one graphics card to another as easily as that :
Intel:
sudo prime-select intel
Nvidia:
sudo prime-select nvidia
Note: A full reboot could be required when switching graphic cards.
@jansanchez for the original gist I based on : https://gist.github.com/jansanchez/ce5b0ca1c5e538f4b266
@JackHack96 for his fork of an ubuntu post install script for the XPS 15 9570, where I've copy the prime-select
script : https://github.com/JackHack96/dell-xps-9570-ubuntu-respin