Software & AppsOperating SystemLinux

How To Install cpupower on Ubuntu 20.04 with Kernel 5.17+

Ubuntu 11

In this guide, we will walk you through the process of installing cpupower on Ubuntu 20.04 running kernel version 5.17 or higher. The cpupower utility is a tool that provides an interface for modifying the frequency scaling and power management features of your CPU.

Quick Answer

To install cpupower on Ubuntu 20.04 with Kernel 5.17+, you can check if it is already installed using the cpupower command. If not, you can install the required packages using apt. If the required packages are not available, you can try installing the generic packages. If none of these options work, you can use primitive commands to modify the CPU frequency scaling driver. However, using primitive commands may not provide the same level of functionality as cpupower.

Checking cpupower Availability

Firstly, you need to check if cpupower is already installed and available for your specific kernel version. Open your terminal and type the following command:

cpupower

If cpupower is installed, you will see a list of available commands. If not, you will receive a warning message indicating that cpupower is not found.

Installing Required Packages

The warning message should provide the package names you need to install. For instance, if the warning suggests installing linux-tools-5.18.5-051805-generic and linux-cloud-tools-5.18.5-051805-generic, you can use the following command to install them:

sudo apt install linux-tools-5.18.5-051805-generic linux-cloud-tools-5.18.5-051805-generic

In the above command, sudo is used to execute the command as a super user, apt is the package handling utility in Ubuntu, install is the command to install new packages, and linux-tools-5.18.5-051805-generic and linux-cloud-tools-5.18.5-051805-generic are the names of the packages to be installed.

Installing Generic Packages

If the required packages are not available for your kernel version, you can try installing the generic packages instead. Use the following command to install the generic packages:

sudo apt install linux-tools-generic linux-cloud-tools-generic

After installing the necessary packages, you should be able to use cpupower by running the command cpupower in the terminal.

Using Primitive Commands

If you are unable to install cpupower for your specific kernel version, you can use primitive commands to modify the CPU frequency scaling driver. These commands involve modifying the values in the /sys/devices/system/cpu/cpu*/cpufreq/ directory.

For example, you can change the scaling governor by echoing the desired governor name to the scaling_governor file:

echo ondemand | sudo tee /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor

In this command, ondemand is the name of the governor you want to set, echo is used to output the string that follows it, | is a pipe that redirects the output of the previous command to the next command, sudo is used to execute the command as a super user, tee is used to write the output to the file specified after it, and /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor is the path to the file where the governor name is to be written.

To change the maximum CPU frequency, echo the desired frequency to the scaling_max_freq file:

echo 4400000 | sudo tee /sys/devices/system/cpu/cpu*/cpufreq/scaling_max_freq

Here, 4400000 is the maximum frequency you want to set in kHz.

Conclusion

In this guide, we have shown you how to install cpupower on Ubuntu 20.04 with kernel 5.17+. We have also shown you how to use primitive commands to modify the CPU frequency scaling driver if cpupower is not available for your specific kernel version. Remember to adjust the values according to your requirements.

Please note that using primitive commands may not provide the same level of functionality as cpupower, especially when it comes to newer features like the amd-pstate driver. If you need the latest features and functionality, you may consider compiling cpupower from the master Linux tree. However, this process requires more advanced knowledge and is not recommended for inexperienced users.

For more information about cpupower and its usage, you can refer to the Linux Kernel Documentation.

How do I check the current CPU frequency scaling governor?

To check the current CPU frequency scaling governor, you can use the following command in the terminal: cpupower frequency-info | grep "scaling governor". This will display the current governor in use.

How do I change the CPU frequency scaling governor?

To change the CPU frequency scaling governor, you can use the cpupower frequency-set command followed by the desired governor option. For example, to set the governor to "ondemand", you can use the command sudo cpupower frequency-set -g ondemand.

How can I view the available CPU frequency scaling governors?

You can view the available CPU frequency scaling governors by using the command cpupower frequency-info --governors. This will display a list of the available governors for your CPU.

How can I change the maximum CPU frequency?

To change the maximum CPU frequency, you can use the cpupower frequency-set command followed by the desired maximum frequency option. For example, to set the maximum frequency to 2.5 GHz, you can use the command sudo cpupower frequency-set --max 2500000.

Can I automate CPU frequency scaling changes?

Yes, you can automate CPU frequency scaling changes by creating a script that sets the desired parameters and scheduling it to run at specific times using tools like cron. This allows you to have different frequency settings based on your needs throughout the day.

How can I monitor CPU frequency and power usage?

You can monitor CPU frequency and power usage using tools like cpupower monitor or powertop. These tools provide real-time information about the CPU frequency, power consumption, and other related metrics.

Can I revert back to the default CPU frequency scaling settings?

Yes, you can revert back to the default CPU frequency scaling settings by using the cpupower frequency-set command with the default governor option. For example, to revert to the default governor, you can use the command sudo cpupower frequency-set -g powersave.

Are there any risks involved in changing CPU frequency scaling settings?

Changing CPU frequency scaling settings is generally safe and supported by the kernel. However, setting incorrect values or using incompatible governors for your CPU may lead to instability or performance issues. It is recommended to do thorough research and understand your CPU’s capabilities before making any changes.

Can I use `cpupower` on other Linux distributions?

Yes, cpupower is available on various Linux distributions. However, the installation process and package names may differ. It is recommended to refer to the documentation or community resources specific to your distribution for detailed instructions on installing and using cpupower.

Is it possible to control CPU frequency scaling on a laptop running on battery power?

Yes, it is possible to control CPU frequency scaling on a laptop running on battery power. By adjusting the CPU frequency scaling settings, you can optimize power consumption to extend battery life.

Leave a Comment

Your email address will not be published. Required fields are marked *