Enabling Hybrid Graphics in Ubuntu on Nvidia + Intel Laptops (OpenGL, Vulkan)

Introduction

This is a simple guide on how to enable intel-nvidia hybrid graphics on a laptop. So that certain applications run on a discrete chip and others on an embedded one. To my surprise, on the Internet, I did not find a simple instruction on how to run certain applications using discrete graphics. So I'll write as simply as I see fit.





I have a KDE Neon 5.21 system - by and large - Ubuntu LTS with a KDE Plasma 5.21 desktop environment, a GeForce MX150 video chip





1. Install the driver

a) If you have a system on Qt (As a rule, the KDE or LXQt environment), then using this command through the terminal, load the program for installing the drivers:





sudo apt install software-properties-qt
      
      



If you have a system on GTK then using this command:





sudo apt install software-properties-gtk
      
      



Although there is no fundamental difference





b) Then run it as root





sudo software-properties-qt
      
      



You can also add a shortcut to launch in the application menu

Instructions for KDE





In the folder, ~/.local/share/applications/



create a file software properties qt.desktop



with the following content





[Desktop Entry]
Categories=System;Settings;
Comment[ru_RU]=drivers
Comment=drivers
Exec=konsole -e "~/.local/share/applications/software-properties-qt.sh"
GenericName[ru_RU]= \s
GenericName= \s
Icon=systemsettings
MimeType=
Name[ru_RU]=software properties qt\n
Name=software properties qt\n
Path=
StartupNotify=true
Terminal=false
TerminalOptions=
Type=Application
X-DBUS-ServiceName=
X-DBUS-StartupType=
X-KDE-SubstituteUID=false
X-KDE-Username=

      
      



And a file software properties qt.sh



in the same folder:





#! /bin/bash
echo software-properties-qt
sudo /usr/bin/software-properties-qt

      
      



After reboot, the shortcut will appear in the menu





But this is far from necessary, it is quite enough to launch the hybrid graphics settings from the console for our purposes.





c) Go to the last tab Additional drivers



and install the required driver. I chose the most recent version, which is not tested



and is notserver







d) After installation, restart the device





2. Configuring the video card

a) :





sudo apt install nvidia-settings
      
      







b) PRIME Profiles



:





  1. NVIDIA (Performance Mode)



    - . , . , .





  2. NVIDIA On-Demand



    - nvidia, - intel.





  3. NVIDIA (Power Saving Mode)



    -





- NVIDIA On-Demand



,





3.

, ...





nvidia OpenGL :





__NV_PRIME_RENDER_OFFLOAD=1
 __GLX_VENDOR_LIBRARY_NAME=nvidia
      
      



Vulkan :





__NV_PRIME_RENDER_OFFLOAD=1
      
      



. , program . :





__NV_PRIME_RENDER_OFFLOAD=1 __GLX_VENDOR_LIBRARY_NAME=nvidia program
      
      



, (.desktop) , . KDE Plasma , ( " ..."), "" .





Example: Shortcut Wolfenstein - Blade of Agony
: Wolfenstein - Blade of Agony

. , Exec=



, __NV_PRIME_RENDER_OFFLOAD=1 __GLX_VENDOR_LIBRARY_NAME=nvidia







, Minecraft
__NV_PRIME_RENDER_OFFLOAD = 1 __GLX_VENDOR_LIBRARY_NAME = nvidia minecraft-launcher
__NV_PRIME_RENDER_OFFLOAD = 1 __GLX_VENDOR_LIBRARY_NAME = nvidia minecraft-launcher

Conclusion

This method, as I understand it, works exactly for programs using the OpenGL and Vulkan libraries. Unfortunately, I didn't manage to run a Windows application through Wine that uses DirectX, but that's a completely different story. (OpenGL applications work under Wine)








All Articles