
In this article, we will guide you on how to set the CPU governor to “performance” in Ubuntu 18.04. The CPU governor is a feature of the Linux kernel that controls the CPU frequency. By setting the CPU governor to “performance”, your CPU will always run at its maximum frequency, which can be beneficial for CPU-intensive tasks.
To set the CPU governor to "performance" in Ubuntu 18.04, you can use either the cpufrequtils package or systemd. With cpufrequtils, you need to install the package, edit the configuration file, disable the ondemand service, and verify the changes. With systemd, you need to create a new systemd service, enable it, and verify the changes.
Method 1: Using cpufrequtils
Step 1: Install cpufrequtils
The first step is to install the cpufrequtils
package. This package provides a suite of utilities to manage and control the CPU frequency. You can install it by running the following command in your terminal:
sudo apt-get install cpufrequtils
Step 2: Edit the cpufrequtils configuration file
Next, you need to edit the configuration file for cpufrequtils
. This file is located at /etc/default/cpufrequtils
. You can use the nano
text editor to edit this file by running:
sudo nano /etc/default/cpufrequtils
In this file, find the line that starts with GOVERNOR=
. Change its value to performance
. This will set the CPU governor to “performance”.
Step 3: Disable the ondemand service
The ondemand
service is a daemon that automatically adjusts the CPU frequency based on the system load. Since we want to set the CPU governor to “performance”, we need to disable this service. You can do this by running:
sudo systemctl disable ondemand
Step 4: Verify the changes
After rebooting your computer, you can check if the CPU governor is set to “performance” by running:
cat /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor
This command reads the current CPU governor from the scaling_governor
file in the /sys/devices/system/cpu/cpu*/cpufreq/
directory.
Method 2: Using systemd
Step 1: Create a new systemd service
Systemd is an init system used in Linux distributions to bootstrap the user space and manage all processes subsequently. You can create a new systemd service to set the CPU governor to “performance” at boot time.
First, create a new systemd service unit file by running:
sudo nano /etc/systemd/system/cpu-performance.service
In this file, paste the following content:
[Unit]
Description=Set CPU governor to performance
[Service]
ExecStart=/usr/bin/cpupower frequency-set --governor performance
[Install]
WantedBy=default.target
This systemd service runs the cpupower frequency-set --governor performance
command at boot time to set the CPU governor to “performance”.
Step 2: Enable the new service
After creating the systemd service, you need to enable it so that it runs at boot time. You can do this by running:
sudo systemctl enable cpu-performance.service
Step 3: Verify the changes
Just like in Method 1, after rebooting your computer, you can check if the CPU governor is set to “performance” by running the same command.
Conclusion
In this article, we have shown you two methods to set the CPU governor to “performance” in Ubuntu 18.04. Please note that setting the CPU governor to “performance” can increase power consumption and heat production. Therefore, use this setting judiciously, especially on laptops or other mobile devices.
Remember that the changes made using these methods are persistent across reboots. If you want to revert to the default CPU governor, you can follow the same steps but replace performance
with ondemand
or powersave
.
We hope this article was helpful. If you have any questions or comments, feel free to leave them in the comment section below.
The CPU governor is a feature of the Linux kernel that controls the CPU frequency. It determines how the CPU dynamically scales its frequency based on the system load.
Setting the CPU governor to "performance" ensures that the CPU always runs at its maximum frequency. This can be beneficial for CPU-intensive tasks that require maximum processing power.
You can install the cpufrequtils
package by running the following command in your terminal: sudo apt-get install cpufrequtils
.
The ondemand
service automatically adjusts the CPU frequency based on the system load. Disabling it ensures that the CPU governor remains set to "performance" and does not switch to other modes based on system demands.
After rebooting your computer, you can run the command cat /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor
in the terminal to check the current CPU governor.
Yes, you can revert to the default CPU governor by following the same steps mentioned in the article but replacing performance
with ondemand
or powersave
.
Yes, setting the CPU governor to "performance" can increase power consumption and heat production. This may be a concern, especially on laptops or other mobile devices. Use this setting judiciously and consider the impact on battery life and system temperature.