Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Some platforms define scaling_max|min_freq but not scaling_cur_freq #1071

Closed
sethmlarson opened this issue May 15, 2017 · 3 comments
Closed

Comments

@sethmlarson
Copy link

This is an issue regarding psutil.cpu_freq() and in this instance the platform is RedHat Linux 7.2. Psutil is installed with Python 3.5.2. When attempting to call psutil.cpu_freq() I receive the following error:

>>> psutil.cpu_freq()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python3.5/site-packages/psutil/__init__.py", line 1895, in cpu_freq
    ret = _psplatform.cpu_freq()
  File "/usr/lib/python3.5/site-packages/psutil/_pslinux.py", line 666, in cpu_freq
    curr = int(cat(os.path.join(path, "scaling_cur_freq"))) / 1000
  File "/usr/lib/python3.5/site-packages/psutil/_pslinux.py", line 298, in cat
    with open_binary(fname) if binary else open_text(fname) as f:
  File "/usr/lib/python3.5/site-packages/psutil/_pslinux.py", line 190, in open_binary
    return open(fname, "rb", **kwargs)
FileNotFoundError: [Errno 2] No such file or directory: '/sys/devices/system/cpu/cpu0/cpufreq/scaling_cur_freq'

This is what I get when I run ls -Al /sys/devices/system/cpu/cpu0/cpufreq

total 0
-r--r--r-- 1 root root 4096 May 15 08:48 affected_cpus
-r-------- 1 root root 4096 May 15 08:48 cpuinfo_cur_freq
-r--r--r-- 1 root root 4096 May 15 08:48 cpuinfo_max_freq
-r--r--r-- 1 root root 4096 May 15 08:48 cpuinfo_min_freq
-r--r--r-- 1 root root 4096 May 15 08:48 cpuinfo_transition_latency
-r--r--r-- 1 root root 4096 May 15 08:48 related_cpus
-r--r--r-- 1 root root 4096 May 15 08:48 scaling_available_governors
-r--r--r-- 1 root root 4096 May 15 08:48 scaling_driver
-rw-r--r-- 1 root root 4096 May 15 08:48 scaling_governor
-rw-r--r-- 1 root root 4096 May 15 08:48 scaling_max_freq
-rw-r--r-- 1 root root 4096 May 15 08:48 scaling_min_freq
-rw-r--r-- 1 root root 4096 May 15 16:50 scaling_setspeed
@giampaolo
Copy link
Owner

It sucks that Linux sucks so much about this. Not sure what to do, whether to set it to 0 or skip to the next frequency.

@giampaolo
Copy link
Owner

OK, I should have fixed this.

@jiabinruan
Copy link

by the way, this file "cpuinfo_cur_freq" can be ready only by root, other user will still got failed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants