-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
[linux] cpu_count_physical is not correct #1620
Comments
This is also related to #1392 and #1558, currently there is no support for getting the number of socket in the system reliably. The number of sockets can be used as a sanity check for number of physical CPUs and can be interesting by itself. |
Could replacing the "set()" with an array resolve the problem? At least on one system I noticed the core_id to only be present for the physical cores...alternately this may provide a work-around to get the number of sockets as being the double-counting factor. (of course if some systems implement a core_id file for the logical cores as well this won't work) |
I've noticed this has broken on my system lately. Some code I wrote used psutil.cpu_count(logical=False) to ensure I was only spawning as many processes as physical cores, and not using hyperthreading. It used to work, but no longer does. Now, psutil.cpu_count() will report the number of real or virtual cores available. Which is the number of physical cores if hyperthreading is disabled, else double that. |
I'm having a related problem.
I have one socket of AMD A10-5757M APU with Radeon(tm) HD Graphics, which counts with two physical cores. I have hyperthreading activated. I've tested Method two in two nodes each with two sockets running CentOS 8 and Centos 7, with kernels 4.18.0 and 3.10.0, respectively. Also, I tested in my PC running Arch with kernel 5.6.2, and I see no reason for Method two to fail. I think we can drop Method one, but someone who knows better the codebase should have the call.
I'm looking forward to contribute. If you want me to make a pull request, please answer this post. |
I didn't investigate this issue yet but if you think you understand the problem and know a solution please make a PR so we'll have more room for discussion. |
Fixed in #1727. |
Platform
Bug description
currently, psutil use '/sys/devices/system/cpu/cpu[0-9]*/topology/core_id' to calculate physical cores, but core id is only uniq in one socket.
Test results
The text was updated successfully, but these errors were encountered: