24

My laptop (an HP with an i3 chip) overheats like crazy every time I run a resource heavy process (like a large compilation, extracting large tarballs or ... playing Flash).

I am currently looking into some cooling solutions but got the idea of limiting global CPU consumption. I figured that if the CPU is capped, chances are the temperature will stop increasing frantically, and I'm willing to sacrifice a little performance in order to get the job done.

  1. Am I wrong in my reasoning?
  2. How can I proceed to cap the CPU usage overall?

If it helps, I'm running Debian.

2
  • I believe you can do this with cgroups, leaving this here as a pointer instead of an answer because I'm not sure, and I'm not sure how exactly...
    – derobert
    Commented Aug 20, 2013 at 14:29
  • You can try to use cgroups. Here is quesiton with similar problem: unix.stackexchange.com/questions/14537/… Commented Jun 1, 2014 at 13:12

6 Answers 6

13

Another alternative that hasn't been mentioned is cpufrequtils, which I have installed and used on my laptop with Debian 6. It allows you to change the algorithm (governor, in cpufrequtils terminology) that the kernel uses to scale the clock rate up and down in response to load - in particular, the userspace governor allows you to lock the frequency at something of your choosing (of course the CPU needs to be capable of running at this speed).

I've used it to lock an Atom at 800MHz instead of 1.6GHz, for example. It's very easy to use.

0
10

I don't know that limiting CPU to the whole system is something that's possible without a lot of hacking, but you can easily limit the amount of CPU used by a single process using cpulimit

The only way I can think of you being able to use this effectively is writing a wrapper script (can't really call it a script, it's so small) for the applications which you know are resource hogs. Say for example, you find google-chrome uses a lot of CPU, you could replace the google-chrome binary in your path with something like:

#! /bin/bash
cpulimit --limit 70 /usr/bin/google-chrome-bin

I haven't tested this so take it with a grain of salt. From cpulimit's website, it seems like you might be able to set rules for cpu limits on different applications. I'm not sure, you'd have to take a look.

7

You can limit your CPU cores automatically based on temperature using the script temp_throttle. It can run in the background while you focus on more important things. An example on how to run:

sudo ./temp_throttle.sh 80 # Will limit CPU cores when 80C is reached.

*Disclaimer- I am the author and maintainer of temp_throttle*

3

Go into bios and underclock the cpu. - No need for cleverness.

3
  • What about for BIOSes which do not support underclocking?
    – daboross
    Commented Jan 26, 2017 at 4:27
  • 1
    use cgroups, but tbh i've not seen a bios that cant change the frequency settings ever.
    – Sirex
    Commented Jan 28, 2017 at 0:03
  • My (admittedly pretty badly built) alienware m14x r1 laptop doesn't have such setting, nothing much available for changing in the bios besides boot order and system time.
    – daboross
    Commented Jan 28, 2017 at 8:26
1

There is no need to change the governor, you just need to change the value of /sys/devices/system/cpu/*/cpufreq/scaling_max_freq for each cpu core.

E.g. with this for loop:

for f in /sys/devices/system/cpu/*/cpufreq/scaling_max_freq; do
    sudo sh -c "echo $1 > $f" 
done

see also my setcpu script.

(original commands found here)

-2

You can use renice to alter the priority of the process by process or group id. From the examples for renice:

  1. Adjust the nice value so that process IDs 987 and 32 would have a lower nice value:

    renice -n 5 -p 987 32

  2. Adjust the nice value so that group IDs 324 and 76 would have a higher nice value, if the user has the appropriate privileges to do so:

    renice -n -4 -g 324 76

  3. Adjust the nice value so that numeric user ID 8 and user sas would have a lower nice value: renice -n 4 -u 8 sas

2
  • 4
    Only a additional note to the answer: renice, nice or other similar tools will not effect in the temperature of the CPU, the problematic process will continue eating the CPU cycles. Commented Aug 23, 2011 at 2:35
  • 2
    Nice and renice won't cap the CPU consumption. They simply set priorities. If nothing else is running at the same time, process will still consume all the processing power.
    – rahmu
    Commented Aug 24, 2011 at 9:09

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .