GPU Manager will overwrite the X configuration at each reboot, so the first step is to disable it.
According to various posts it can be disabled adding nogpumanager to the boot options e.g. in GRUB.
Edit /etc/default/grub and add nogpumanager to the GRUB_CMDLINE_LINUX option.
For example, if /etc/default/grub had
GRUB_CMDLINE_LINUX=""
change it to
GRUB_CMDLINE_LINUX="nogpumanager"
Then update GRUB:
$ sudo update-grub
Generating grub configuration file ...
Found linux image: /boot/vmlinuz-4.18.0-10-generic
Found initrd image: /boot/initrd.img-4.18.0-10-generic
Adding boot menu entry for EFI firmware configuration
done$ sudo apt install bumblebee-nvidiashould install Bumblebee and all the necessary dependencies.
Once it is done, check that the bbswitch module is available and loaded:
$ lsmod | grep bbswitch
bbswitch 16384 0It should also have blacklisted the nouveau driver:
$ head /etc/modprobe.d/bumblebee.conf
# This file is installed by bumblebee, do NOT edit!
# to be used by kmod / module-init-tools, and installed in /etc/modprobe.d/
# or equivalent
# do not automatically load nouveau as it may prevent nvidia from loading
blacklist nouveau
# do not automatically load nvidia as it's unloaded anyway when bumblebeed
# starts and may fail bumblebeed to disable the card in a race condition.
# Debian
blacklist nvidiaGenerate a clean Xorg configuration file:
$ sudo -i Xorg :1 -configure
X.Org X Server 1.20.1
X Protocol Version 11, Revision 0
...
(++) Using config file: "/root/xorg.conf.new"
(==) Using system config directory "/usr/share/X11/xorg.conf.d"
Number of created screens does not match number of detected devices.
Configuration failed.
(EE) Server terminated with error (2). Closing log file.The newly-generated /root/xorg.conf.new will likely try to configure the Intel card and one for the NVIDIA card at the same time.
Remove the references to the NVIDIA part, e.g. the Card1 Device section, the Monitor1 Monitor section, and the Screen1 screen section.
Make any other adjustments you may want, then copy the file to /etc/X11/:
sudo cp /root/xorg.conf.new /etc/X11/xorg.confNow reboot, in order to apply all the changes.
Add the PPA to get the latest proprietary drivers:
$ sudo add-apt-repository ppa:graphics-drivers/ppa
$ sudo apt updateFind out what is the latest available version, and install it:
$ apt-cache search nvidia-driver | grep ^nvidia-driver
$ sudo apt install nvidia-driver-410If the last command fails with conflicts about xserver-xorg-video-nvidia-390, try manually applying some of the changes:
$ sudo dpkg --force all -P xserver-xorg-video-nvidia-390 libnvidia-cfg1-390
$ sudo apt install xserver-xorg-video-nvidia-410 libnvidia-cfg1-410
$ sudo apt install nvidia-driver-410Edit /etc/bumblebee/bumblebee.conf and change these keys:
[bumblebeed]
Driver=nvidia
[optirun]
Bridge=primus
[driver-nvidia]
PMMethod=bbswitch
LibraryPath=/usr/lib/x86_64-linux-gnu:/usr/lib/i386-linux-gnu
XorgModulePath=/usr/lib/x86_64-linux-gnu/nvidia/xorg,/usr/lib/xorg/modules
Then reload the bumblebee daemon:
$ sudo systemctl restart bumblebeed$ echo 'export __GLVND_DISALLOW_PATCHING=1' | sudo tee /etc/profile.d/disable-glvnd.shYou will need to reboot to propagate the environment variable to the running sessions. In the meantime, it can be set explicitly (see the next point).
See this post for some background information.
Open a new terminal and run:
$ export __GLVND_DISALLOW_PATCHING=1
$ optirun glxgears
291 frames in 5.0 seconds = 58.033 FPS
300 frames in 5.0 seconds = 59.992 FPS
300 frames in 5.0 seconds = 59.998 FPS
...If it works, congratulations, your system is configured to run standaerd operations with the Intel card and offload on-demand to the NVIDIA card.