Search code examples
pythoncpucpu-usagefrequency

cpufreq throws error, not finding a file in centOS 7


I'm trying to run only:

import cpufreq
Cf = cpufreq.cpuFreq()

It throws this error: FileNotFoundError: [Errno 2] No such file or directory: '/sys/devices/system/cpu/cpu0/cpufreq/scaling_available_frequencies'

I'm stuck here, I'm using cpufreq to change cpu frequency


Solution

  • Only certain processors and architectures support reading or adjusting the frequency. See https://superuser.com/questions/533507/how-can-i-manually-set-the-cpu-frequency . In addition to processor support, the kernel has to be configured for it as well, and CentOS 7 is an antique.

    FOLLOWUP

    The only practical method for doing this on Windows is to use the BIOS.

    Now, let me make a speech. The processor vendor, the system OEM, and and the operating system vendor have a very strong incentive to give you the best possible performance. The power and clock management modules in your chip and your operating system are ENORMOUSLY complicated. You cannot imagine the tens of thousands of lines of code involved here. They are using inputs based on system load, chip temperature, fan speed, and power usage, and feeding those into time-based formulas that adjust the frequency automatically. In some cases, the frequency is adjusted tens or hundreds of times per second. I'm not sure what you might be planning, but much like dinking with priorities and thread affinity, ANYTHING YOU DO IS JUST GOING TO MAKE THINGS WORSE. If you're a hard-core gamer, then you've enabled BIOS-based overclocking and added an aftermarket cooling system to support that, but playing with frequencies on the fly is counter-productive.