20

When I start my Unity desktop the CPU indicator shows only one bar and it is set to Powersave. When I switch to Performance I have to enter an admin users password.

But after system restart my CPU is back in Powersave. How to set Performance as the default, so I don't have to switch it after every restart?

Witek
  • 3,933
  • 1
    Does https://askubuntu.com/a/445595/639369 help? In short edit /etc/init.d/cpufrequtils to set CPU governor to (in this case) performance on startup. – Kees Beets Jul 13 '17 at 21:31

3 Answers3

31

Performance and Powersave Governor Policies

There are various options for setting CPU governor policy described in Ask Ubuntu and other websites:

Keep in mind most websites suggest leaving CPU governing at Powersave. I'm on a laptop and found using Intel's ThermalD and P-State technologies coupled with TLP power management has best result for frequencies, fan speed and temperature.

Summarizing above links

To summarize achieving your goal from the above answers use:

Install cpufrequtils:

sudo apt-get install cpufrequtils

Then edit the following file (if it doesn't exist, create it):

sudo nano /etc/default/cpufrequtils

And add the following line to it:

GOVERNOR="performance"

Save and exit.

For changes take effect, run:

sudo systemctl restart cpufrequtils

Then you can run cpufreq-info to see informations about your cpu frequency, governor and more:

$ cpufreq-info
    current policy: frequency should be within 800 MHz and 3.90 GHz.
              The governor "performance" may decide which speed to use
              within this range.

As per this Q&A: Set CPU governor to performance in 18.04

If you want performance governor all the time you need to edit /etc/rc.local and insert these lines before the last line containing exit 0:

sleep 120 # Give CPU startup routines time to settle.
cpupower frequency-set --governor performance

To setup /etc/rc.local in 18.04 see: How to Enable /etc/rc.local with Systemd

  • 3
    This is also applicable to Ubuntu 18.04 and 18.10 just in case anyone is wondering... – der_michael Dec 11 '18 at 05:57
  • Appears to be working in 20.04 Kubuntu. How can you revert this change in the same session without rebooting? Here's the scenario, I want to set the governor to performance before I enter a game and back to powersave after I'm done. – El-Chief Aug 09 '20 at 14:08
  • @el-banto I added a new section to the answer. In your case you can try: echo powersave | tee /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor when game is finished. Hopefully that works as it is the simplest method. – WinEunuuchs2Unix Aug 09 '20 at 15:30
  • Thanks, can I just echo performance as well instead of using cpufrequtils? – El-Chief Aug 09 '20 at 20:04
  • @el-banto Yes that is the simplest, but you have to wait 1 minute after boot because it is set to performance during first minute to speed up boot then set to powersave. – WinEunuuchs2Unix Aug 09 '20 at 21:05
  • @WinEunuuchs2Unix The echo command didn't work unfortunately. Even with sudo, I'm getting permission denied errors. – El-Chief Aug 11 '20 at 14:30
  • @el-banto The sudo goes in a different spot using tee command. For example: echo performance | sudo tee /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor – WinEunuuchs2Unix Aug 11 '20 at 15:54
  • Cheers, it works great now! – El-Chief Aug 11 '20 at 16:04
7

I cannot comment because I have low reputation but I want to add the accepted answer. You will also need to run

sudo /etc/init.d/cpufrequtils restart

for this to take effect on your system. You should then see your frequencies hovering around the max listed and

current policy: frequency should be within 800 MHz and 3.90 GHz.
              The governor "performance" may decide which speed to use
              within this range.

When you type cpufreq-info

1

I'm on Xubuntu 18.04.02 LTS and installing cpufrequtils by sudo apt-get install cpufrequtils, made it possible to reduce the max CPU-speed. A nice option to have as the fan has stopped working.

After looking at the info by cpufreq-info, I created a file by sudo nano /etc/default/cpufrequtils, and wrote into it as in picture below. I found out it was of use to also set a value for min speed.

enter image description here

Lastly the command to make the change take action sudo /etc/init.d/cpufrequtils restart, resulting in this output from cpufreq-info:

enter image description here

To be clear - this is off course not my own findings, only a result of conclusions made from other earlier questions, comments, and answers on this forum. Especially the answer in this very question from WinEunuuchs2Unix.