NVIDIA Optimus + bbswitch
This guide will show you how you can use Optimus in order to optimize battery performace. With bbswitch you can switch on or off your NVIDIA dGPU based on your needs and in turn safe valuable power and battery!
I will assume that
- You have already installed Ubuntu
- You have already installed NVIDIA drivers
Use Intel GPU – i915 – as your main graphics adapter
Configure grub:
# Open blacklist.conf
sudo nano /etc/default/grub
# Append
GRUB_CMDLINE_LINUX_DEFAULT="nomodeset nogpumanager i915.modeset=1 [...]"
# Save file and update GRUB configuration
sudo update-grub2
Disable gpu-manager.service for systemctl
sudo systemctl mask gpu-manager.service
Blacklist nouveau and nvidia drivers
Basically we will blacklist all drivers that can be used with the NVIDIA GPU or dGPU.
# Open blacklist.conf
sudo nano /etc/modprobe.d/blacklist.conf
# Go to the end and add
blacklist nouveau
blacklist lbm-nouveau
alias nouveau off
alias lbm-nouveau off
options nouveau modeset=0
blacklist nvidia
blacklist mvidia-uvm
blacklist mvidia-drm
blacklist nvidia-modeset
Install bbswitch
To install bbswitch run:
sudo apt install bbswitch-dkms
Edit /etc/modules to load i915 and bbswitch during boot
sudo nano /etc/modules
# Append
bbswitch
i915
Configure bbswitch initial state to off:
# Create new file
sudo nano /etc/modprobe.d/bbswitch.conf
# And add
options bbswitch load_state=0
Update initramfs:
sudo update-initramfs -u -k all
Reboot!
Surface Book 2: qzed custom kernels
For people using the new custom kernels from qzed, you need to perform some extra steps to enable/disable the graphics card.
Prerequisites
Make sure you have commented out all the aliases on the /lib/modprobe.d/blacklist-nvidia.conf . E.g.:
# Do not modify
# This file was generated by nvidia-prime
blacklist nvidia
blacklist nvidia-drm
blacklist nvidia-modeset
#alias nvidia off
#alias nvidia-drm off
#alias nvidia-modeset off
Reboot!
Install surface-control
To enable/disabale your GPU you need the surface-control tool. Download the latest .deb file and install it.
Enable and use the GPU
# Power-on the GPU
sudo surface dgpu set on
# Power-off the GPU
sudo surface dgpu set off
# Check if powered on with lspci --> GPU should appear on the PCI bus
Once powered on, you need to load the nvidia kernel module, assuming you have installed the nvidia-modprobe:
sudo nvidia-modprobe
Now check if the nvidia module has been loaded with sudo lspci -nnk. This is an example output:
02:00.0 3D controller [0302]: NVIDIA Corporation GP106M [GeForce GTX 1060 Mobile] [10de:1c20] (rev a1)
Subsystem: Microsoft Corporation GP106M [GeForce GTX 1060 Mobile] [1414:0024]
Kernel driver in use: nvidia
Kernel modules: nouveau, nvidia_drm, nvidia