Build and Install the PREEMPT_RT Linux Kernel¶
To get good real-time performance on Linux, we recommend using a Linux kernel with the PREEMPT_RT patch. Unfortunately, this requires one to build the kernel from source (at least on Ubuntu). We provide some help for this in the following.
Note that Nvidia drivers do officially not support the PREEMPT_RT patch. It may still work (see Using Nvidia Drivers with the PREEMPT_RT Kernel below) but you are at your own risk.
An alternative may be the “lowlatency” kernel. It is easier to install and works with Nvidia drivers but has weaker real-time capabilities (see Installation: Low-latency vs PREEMPT_RT Kernel).
Install PREEMPT_RT Kernel¶
To install the patched kernel on Ubuntu, you may use our script
install_rt_preempt_kernel.sh
. We provide adapted versions for different Ubuntu
versions, which can be found here.
The VERSION_
variables at the top of the script refer to the kernel version that
will be installed. Usually you can leave the default values, but you can change it here
if you want a different version. See preempt_rt_versions for available versions.
Then simply execute the script in a terminal. Internally, sudo is used in some steps, so the user executing it needs to have sudo-permission.
Note
In the beginning (after downloading some things) you will be asked to manually adjust some configuration settings. Before entering the menu, the script prints instructions like the following:
Please apply the following configurations in the next step:
[...]
General setup [Enter]
Preemption Model (Voluntary Kernel Preemption (Desktop)) [Enter]
Fully Preemptible Kernel (RT) [Enter] #Select
However, depending on the kernel version the “Preemption Model” setting may be found in the “Processor type and features” menu instead.
The script will automatically download, build and install the kernel. This will take a while.
When finished, go back to Real Time Setup and follow the further steps to configure your system for real-time usage.
Using Nvidia Drivers with the PREEMPT_RT Kernel¶
Officially, Nvidia drivers do not support the PREEMPT_RT kernel. However, at least with
more recent versions, it seems to work in practice. However, you need set the
environment variable IGNORE_PREEMPT_RT_PRESENCE=1
when installing it with apt.
Complete steps:
First uninstall any Nvidia drivers
Install the PREEMPT_RT kernel (see above)
Install the drivers with the following command (adjust driver version to the desired one):
sudo IGNORE_PREEMPT_RT_PRESENCE=1 apt install nvidia-driver-530
Please note that this variable also needs to be set when upgrading packages, so you may want to set it in a global place like /etc/environment and disable unattended upgrades for the driver.