Skip to content

Instantly share code, notes, and snippets.

@haipnh
Last active April 25, 2024 10:37
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save haipnh/565cce0c4e1fb878b093d3faf7b37114 to your computer and use it in GitHub Desktop.
Save haipnh/565cce0c4e1fb878b093d3faf7b37114 to your computer and use it in GitHub Desktop.
Intel for display, NVIDIA for computing and offload rendering

Purposes

  1. iGPU will be used for main display and rendering daily-use softwares in default
  2. Dedicated GPUs will be used for computing or offload rendering
  3. Reduce the used VRAM of Dedicated GPU, which is mostly used for X11 server rendering

Tested Hardware Configuration

OS: Ubuntu 18.04.4 LTS
Mainboads
├── iGPU
│   ├── HDMI -> Monitor 1
│   └── DisplayPort -> Monitor 2
├── GTX 1080 Ti
│   └── Any port (unused)
└── GTX 1650
    └── Any port (unused)

Prerequiresite

  • After the Ubuntu installation, your system can boot into GUI and detect multiple monitors with full resolution. That means iGPU works out-of-the-box. Otherwise you need to install iGPU driver.

Installation

Step 1: Check iGPU driver

Open Terminal and execute lshw -c video to check (1) which driver of iGPU is being used and (2) the bus id of iGPU. For instance, Intel iGPU uses intel or i915 driver, and its bus id is pci@0000:00:02.0 in most cases.

Step 2: X11 Configuration

Execute sudo nano /etc/X11/xorg.conf to add these configuration.

Section "ServerLayout"
    Identifier "Layout0"
    Screen 0 "Screen0"
    Option "AllowNVIDIAGPUScreens"
EndSection

Section "Screen"
    Identifier "Screen0"
    Device "Device0"
EndSection

Section "Device"
    Identifier "Device0"
    Driver "i915"
    VendorName "Intel Corporation"
    BusID "PCI:0:2:0"
EndSection

Step 3. Install NVIDIA driver

Option 1: NVIDIA GPU is for computing only, no rendering
sudo apt install nvidia-headless-515 nvidia-utils-515
Option 2: NVIDIA GPU is for both computing and rendering
  1. Install
sudo apt install nvidia-driver-515
  1. Open Terminal and execute nvidia-settings to open "NVIDIA X Server Settings". In PRIME Profiles, choose NVIDIA On-Demand
Note: You should check for the latest version rather than 515.

Step 4. Reboot system


Verification

1. To see if the NVIDIA driver is loaded

lsmod | grep nvidia_drm

If not, manually load it to linux kernel

sudo modprobe nvidia_drm

2. To verify GPU creation

cat /var/log/Xorg.0.log

and the query result by executing xrandr --listproviders should show that the Providers: number : is more than 1.

3. To see which device is being used for main display

glxheads

4. To offload rendering (only for Option 2)

__NV_PRIME_RENDER_OFFLOAD=1 __GLX_VENDOR_LIBRARY_NAME=nvidia glxheads

Now you simply set an alias to offload rendering in needed.

echo "alias offload-render='__NV_PRIME_RENDER_OFFLOAD=1 __GLX_VENDOR_LIBRARY_NAME=nvidia'" >> ~/.bashrc
source ~/.bashrc
offload-render glxheads

Reference

[1] https://gist.github.com/wangruohui/bc7b9f424e3d5deb0c0b8bba990b1bc5

[2] https://download.nvidia.com/XFree86/Linux-x86_64/435.17/README/primerenderoffload.html

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment