Pages

Wednesday, October 12, 2011

How to set the CPU voltage

Hey guys,

here I am, I bet that soon or late you were waiting for this piece of knowledge.... I guess a little late, but here it comes. In the following guide you'll learn how to save energy, lower CPU temperature and improve your battery duration (at least on laptops) without (or at least minimizing) bugs and freezing, by setting the voltages of your CPU. If you don't have phctool installed take a look here:



First of all remember that doing those stuff your system might crash without saying "Hey dude, kinda confused here, I'm gonna make a mess soon". So no precious file copying, no disc burning, no thesis writing... I hope you got it, better nothing at all.

Tools

We need few stuff:
  • Patience: of course this is what does the job.
  • Stress tool: we need something to set the clock to be stressed, and something to put under heavy load the cpu, to see if it fails...  so:
    sudo apt-get install cpuburn cpufrequtils lm-sensors
Ok, what have we installed? Cpuburn it's a set of commands, each one built for a specific CPU, that make one CPU core the busiest possible. Cpufrequtils instead gives us the possibility to set the CPU frequency step as we like. At last lm-sensors is a suite to get hardware infos form your box. To install it (from ubuntu HowTo):
  1. Run
    sudo sensors-detect
    and answer YES to all YES/no questions.
  2. At the end of sensors-detect, a list of modules that needs to be loaded will displayed. Type "yes" to have sensors-detect insert those modules into /etc/modules.
  3. Next, run "sudo /etc/init.d/module-init-tools restart". This will read the changes you made to /etc/modules in step 2, and insert the new modules into the kernel.
Once you have a working installation of lm-sensors, we have a good way to keep temperatures under control: open a new terminal and launch
while [ true ]; do sensors; sleep 1; done 
Keep it running in another window and go on with our mission!

How to stress

To stress a CPU you have to run one of the cpuburn commands. They are a big family, but can be split in two: burnP* are for intel CPUs, burnK* for AMD ones. So, if you have already opened sensors to keep temperatures under control (last command), the thing to do is just launch from terminal:
burnP6 &
the "&" is needed as we have to stress all the cores, so we have to repeat that command for each core. Be sure to write immediately after the last "burn"
killall burnP6
so you can be ready to stop the test if a too high temperature is reached. If the computer does not freeze and the temperature does not blow your box up at least for a couple of minutes, you have 95% of probability to be on an actually stable setting. To be 99% sure you should run the burn test for 10-15 minutes.

Tuning Voltages
  1. The first step is of course to open phctool and take a look at the voltages. In that tab you can see both the frequency steps and the voltages. If you have more than one core you should see on your right several CPUs: you can set and stress all the cores at the same time.
  2. Now open another terminal: we will use this to change the CPU frequencies and stress them. To get some extra info start with:
  3. sudo cpufreq-info
    And take note of your CPU governor.
  4. Repeat the following operations for all the cores you have(-c 0; -c 1 ... etc):
  5. sudo cpufreq-set -c 0 -g userspace
    Like this we are able to set our CPU voltage as we like. 
  6. From phctool set the lowest freq @ the lowest voltage for all the cores.
  7. Launch:
    sudo cpufreq-set -c 0 -f **the freq value**
    **the freq value** has to be written in the human readable format, just without space (e.g. 800MHz or 1.2GHz ect)
  8. Now we are not sure to be actually using the lowest voltage, to check that go to the analysis tab of phctool and refresh. If you get a wrong [target voltage]/frequency double check what have you done... if it doesn't work for no reason just leave a comment.
  9. If the current voltage does not match the target VID then you have some limitation on the motherboard... so don't struggle on how to workaround it, it depends on your mobo/cpu hardware capablities. So take it as the "absolute zero", set it so that current and target VIDs match, and start stress it. 
  10. If the stress test is ok we can move on. The following procedure has to be cycled for all the freq available, for all the cores:

    • Ø_ Set the frequency (of all the cores) with cpufreq-set:
      sudo cpufreq-set -c 0 -f **the freq value**
      Your Voltage Quantum Q is now 0.1V
    • A_   Lower the VID (of all the cores) @ that freq by Q
    • B_   Stress test the value @ that freq
    • C_  if the test failed halve Q and set the VID (of all the cores) to the last stable value. If Q is smaller than the VID step then go to the next point, otherwise return to A_
    • D_ If you are here you have configured almost at the limit that freq VID. If you want to be safer increase it of a couple of steps (for all the cores). Now move to the next frequency and restart from Ø_.
  11. If you completed these operations for all the cores and all the frequencies now you have tuned your box! Remember to set "restore VIDs on load" before you can call it a day ^_^
I think we are done. If you need any help (but even if you don't need it) feel free to leave a comment!



Cheers!

14 comments:

  1. My freq configs are being overwrited after few minutes. I`ve a AMD Turion X2, running a Kubuntu 11.10. I searched e tried a lot of things on web, but nothing. Can you help-me?

    ReplyDelete
  2. @LEANDRW

    What method do you use to set the VIDs? Have you tried the GUI?

    ReplyDelete
  3. I don't show anything for step 6. above, everything is just "n/a". I have a Sandy Bridge quadcore; only 2 of the cores are listed by the phctool -- 0 and 3 -- (is there some way to configure it to recognize all four)? Also, phctool says that it doesn't recognize the cpu under Info>Vcc calculation. What next?

    ReplyDelete
    Replies
    1. It seems your hardware has some trouble, but don't struggle... it seems they're messing up some stuff, try to open a thread in their forum... Developers should help you debuggin...

      just leave a message here: http://www.linux-phc.org/forum/index.php

      Cheers

      Delete
    2. I also have the Sandy Bridge and the same showing only cores 0 and 3. So does Undervolting not work on the Intel Core I5?

      Delete
  4. I'm lost and need some clarification if this program actually works with my computer.

    This is what phctool looks like on my computer:
    http://i.imgur.com/ToqUG.png
    http://i.imgur.com/JGDcq.png

    And this is where i'm currently at:
    http://i.imgur.com/lwIla.png
    burnP6 & boosts the cpu and it also detects my temps, but when I insert 800mhz into every cpu I don't get any info after hitting refresh in Analysis, so i'm a bit confused if this works on my computer or not?.

    I'm trying to take it step by step since this is a beyond my knowledge.

    ReplyDelete
    Replies
    1. Sorry, but your CPU seems to be not supported. Please issue a support thread on www.linux-phc.org, in the PHC section: http://www.linux-phc.org/forum/viewforum.php?f=8&sid=71321d20e54850f6d2b66b35c2c142ac

      Regards

      Delete
  5. Hi and thank you for the tutorials. I am a total noob. I followed your tutorial for undervolting in 12.04, and all seemed ok. However, I am a little lost with these instructions for finding the optimal VIDs.

    Question 1: Do I type in burnP6 &? or burnP* &? or burnP1 &? I don't understand how to repeat that for each core.

    Question 2:I tried using burnP6 & and the temperatures started to climb. I got nervous, so ran killall burnP6 but I'm not sure if I was supposed to let it run for a while (I didn't understand "last burn")

    Question 3: Why do I need to note the "governer"? Does that get used later?

    Question 4: What does "set the lowest freq @ the lowest voltage for all the cores." mean? Do I set the lowest freq to zero? And then save?

    Sorry, I don't understand! I'm a total noob...maybe if you can answer those questions, the rest will make sense.

    Or maybe my hardware doesn't allow? In the PHCtools, I can lower all the VID's from the set values to zero (lowest), so I'm assuming the hardware does in fact allow it.

    Thanks!

    ReplyDelete
    Replies
    1. Hey, first let me tell you this is not as easy as it seems, so if you are really "noob" as you said ask yourself if it worths the try... Anyway:

      1 BurnP6 & if you have an intel, but repeat it one time for each core you have

      2 The purpose of burn** is to stress your cpu and let it heat ad much as possible... you have to be ready to kill the tasks if something is about to blow (over 100C it will)

      3 It is needed to be restored when you are done... I forgot about it :P

      4 Yep, that is the idea, but that doesn't mean the voltage is really 0 ^_^...

      Once again, be sure of what you do!

      Regards


      Delete
  6. Hi Fabio-Great stuff here.

    I think i went through all the steps on my x41 Tablet. I am not sure, however, if the changes i made in the phctool gui are actually being implemented. What i mean to ask is : if one makes a change in phctool gui, does it immediately change the voltages ? Are there other commands one needs to give in a terminal to make it "active". I modified the VID settings based on some values I found for an X40 Thinkpad. I didnt notice anything immediate though. I have a fan control program that senses temperatures and I didn't see any drop as of yet (been about an hour or so)

    Second question

    If i see throttling: Not available in the phctool gui, what does this mean?

    Current VID's under the analysis tab displays the changes i implemented. I guess this is a good sign?

    ReplyDelete
    Replies
    1. Of course it is a good sign. That analysis report is built directly reading processors registers so it sates you're doing it right.

      About temperatures, I prefer to rely on values detected directly by 'sensors' command, coming with lmsensor interface, since it returns the values as they are detected. A good way to monitor is to issue:

      while true; do clear; sensors; sleep 1; done

      and, when you're done, terminate it by ctrl+C.

      Throttling is an heritage of the older drivers, so latest acpi-cpufreq (which phc-* drivers are based on) do not have that interface anymore, but I kept the tab just for back-compatibility.

      Cheers

      Delete
  7. Tip: you can use "watch -n 1 sensors" and it will update the screen with the output automatically each second, without polluting the terminal.

    ReplyDelete
  8. http://imgur.com/a/1qkD8

    I think I have it installed but it's not detecting the CPU correctly. I locked the processor to 2.9ghz and put it under stress and my wattage meter read higher wattage as I tried to lower the VID for it. Should be going down I would think, so something is wrong there.

    Also, there's something wrong with the one of the spam fields on the account creation to the forum, so I couldn't make an account to post this there. The one you have to leave blank doesn't go blank.

    ReplyDelete
  9. "Acquisto prodotti per DJ online, migliaia di prodotti in pronta consenga come consolle, mixer, cuffie, lettori
    MP3, Acquisto Strumenti Musicali online, chitarre, bassi, batterie, effetti a pedale, Acquisto attrezzature musicali
    online, casse attive, amplificatori, studio monitor, microfoni, home recording,overvolt"

    ReplyDelete