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

[WIndows 11 23H2] cpu_percent percpu=True shows realistic CPU load only for one core #2467

Open
Extiward opened this issue Oct 28, 2024 · 0 comments

Comments

@Extiward
Copy link

Extiward commented Oct 28, 2024

Summary

  • OS: Windows 11 Pro 23H2 22631.4317
  • Architecture: 64bit
  • Psutil version: 6.1.0
  • Python version: 3.11.9
  • Type: core

Description

When using cpu_percent with percpu=False to display CPU load the value is always much lower than expected, e.g. cpu_percent returns load or single digit percent, while CPU actually is loaded to e.g. 50-70% (when looking at Task Manager). When using percpu=True only one element in the array contains large number (the high load element seems to change from run to run), which roughly corresponds to the full CPU utilization (see output example below). CPU has 12 cores and 24 threads.

Code snippet:

while True:
            cpu_load = psutil.cpu_percent(interval=1, percpu=True)

            print(f"CPU load: {cpu_load}%")
            time.sleep(1)

Example output:
CPU load: [0.0, 0.0, 1.6, 3.1, 0.0, 3.1, 0.0, 4.7, 0.0, 0.0, 0.0, 1.6, 0.0, 4.7, 1.6, 0.0, 1.6, 3.1, 3.1, 0.0, 0.0, 3.1, 1.6, 42.4]%
CPU load: [3.1, 3.1, 6.2, 1.6, 0.0, 3.1, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.6, 0.0, 0.0, 1.6, 0.0, 0.0, 3.1, 1.6, 41.5]%
CPU load: [0.0, 1.6, 6.2, 6.2, 0.0, 0.0, 1.6, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 3.1, 0.0, 0.0, 0.0, 0.0, 0.0, 70.1]%
CPU load: [4.6, 0.0, 3.1, 4.7, 0.0, 1.6, 1.6, 1.6, 1.6, 1.6, 4.7, 3.1, 0.0, 3.1, 10.9, 3.1, 0.0, 4.7, 3.1, 10.9, 1.6, 0.0, 3.1, 50.0]%
CPU load: [0.0, 0.0, 0.0, 6.3, 0.0, 0.0, 1.6, 3.1, 0.0, 0.0, 3.1, 0.0, 0.0, 3.1, 3.1, 1.6, 1.6, 3.1, 0.0, 3.1, 0.0, 1.6, 0.0, 35.4]%

image

That can't be correct behavior. Expected result would be to have roughly even load across all cores as seen in the attached screenshot.

@Extiward Extiward added the bug label Oct 28, 2024
@Extiward Extiward changed the title [WIndows 11 23H2] cpu_percent percpu=True shows realisting CPU load only for the last core [WIndows 11 23H2] cpu_percent percpu=True shows realistic CPU load only for the last core Oct 28, 2024
@Extiward Extiward changed the title [WIndows 11 23H2] cpu_percent percpu=True shows realistic CPU load only for the last core [WIndows 11 23H2] cpu_percent percpu=True shows realistic CPU load only for one core Oct 28, 2024
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

1 participant