Tuesday 22 January 2019

How to use Intel GPU for desktop display and dedicate Nvidia GPU (nvidia-415 and above) for CUDA in Ubuntu?

Nvidia has updated their graphics driver, so in the latest nvidia-415, my previous solution (2017.9 "How to use Intel GPU for desktop display and dedicate Nvidia GPU for CUDA in Ubuntu?") no longer works.

Here is the updated solution to deal with the new driver:
METHOD A:
1. You still select Nvidia by "sudo prime-select nvidia"
2. add the following in /etc/X11/xorg.conf

Section "Device"
    Identifier      "intel"
    Driver          "intel"
    BusId           "PCI:0:2:0"
EndSection

Section "Screen"
    Identifier      "intel"
    Device          "intel"
EndSection
where the BusId is the PCI address of your integrated graphics card (run lspci).


METHOD B:
1. To use Intel GPU to display desktop environment, you first need to switch to Intel GPU using "sudo prime-select intel" and reboot.

2a. Every time after entering desktop, you need to run the following command to load the kernel driver:
sudo modprobe ipmi_msghandler
sudo insmod /lib/modules/$(uname -r)/updates/dkms/nvidia.ko

Take note that as Nvidia keeps updating their driver:
- the filename and location of nvidia.ko might change, you need to know these every time you install the Nvidia driver.
- its dependency kernel module, ipmi_msghandler, might also change. You can use modinfo to check Nvidia kernel driver's dependency

2b. Alternatively (instead of 2a), you can simply run the following command to load Nvidia driver:
sudo prime-select nvidia
sudo modprobe nvidia
sudo prime-select intel