You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Wrong number of CPU cores detected in Windows Server multi Processor Group environment #771
api-changean existing public API changed, was deprecated or removedbugtypecompatibilityworking installs or working code have to changewindowsplatform : Windows specific
When running psutil.cpu_count(logical=False) I am getting 60 instead of 120 cores. Similarly when running psutil.cpu_percent(interval=1, percpu=True) I am getting utilization just for half of the CPU cores.
My system has two Processor Groups (each with 60 cores) and it seams that psutil is not processor group aware. On large systems processor resources are split into groups and it requires using special API to get correct numbers.
Sorry for such a big delay in responding. Can you provide more info about what kind of processors are these? Otherwise I really have no idea what kind of alternative API we could use.
I have eight Xeons E7-2890 v2 with 15 cores each. My first guess would be NUMA architecture and Processor Group awareness rather then type of CPU. I was having the same issues on different system with 80 cores and different CPU model.
This is probably nothing new but maybe will give some different perspective:
I see this issue in many programs. They are all processor groups unaware recognizing only group0.
This is how NUMA nodes look like in my case:
One can see there are eight NUMA nodes, each has one CPU with 15 cores. The nodes 0,1,4 and 5 are grouped into GROUP0, the remaining nodes make GROUP1.
The phython.exe instance which I run psutil from was assigned by OS (or picked itself) GROUP1:
This means it will be unable using group2 resources and that’s why it returned len(psutil.cpu_times(percpu=True)) 60 instead of 120
One workaround would be to start second python.exe process making sure it is assigned to another group and gather statistics including CPUs count from this process.
To make it generic algorithm would have to “
1. count total number of groups (because there may and will be more groups on other systems. Mine is only 50% populated, I will add two more groups and another 120 CPUs in the future)
2. for each group start separate process enforcing different and unique affinity (assignment to specific group)
3. compute in parallel statistics in all processes
4. gather and integrate data from distributed processes into a single instance for reporting
5. shut down all the processes except master one
dwNumberOfProcessors
The number of logical processors in the current group.
Note For information about the physical processors shared by logical processors,
call GetLogicalProcessorInformationEx with the RelationshipType parameter set to
RelationProcessorPackage (3).
When this function is called with a relationship type of
RelationProcessorCore, it returns a PROCESSOR_RELATIONSHIP
structure for every active processor core in every processor group
in the system.
I know it may be inefficient, but I can run code for you on my system and send back the output if this helps.
---
Main problem is that I don't have the right hardware to test this against.
On 02 Dec 2016, at 23:19, twisniewski78 ***@***.***> wrote:
I know it may be inefficient, but I can run code for you on my system and send back the output if this helps.
From: giampaolo ***@***.***
Sent: Friday, December 2, 2016 8:57 AM
To: giampaolo/psutil ***@***.***>
Cc: twisniewski78 ***@***.***>; Author ***@***.***>
Subject: Re: [giampaolo/psutil] Wrong number of CPU cores detected in Windows Server multi Processor Group environment (#771)
Main problem is that I don't have the right hardware to test this against.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub <#771 (comment)> , or mute the thread <https://github.com/notifications/unsubscribe-auth/AQeYyM_tjkw3Nx69xlAxcHp4WH0JwvRrks5rECOWgaJpZM4HbQUI> . <https://github.com/notifications/beacon/AQeYyNEPTEV-rq9uOv91PQoRiCrRjIJhks5rECOWgaJpZM4HbQUI.gif>
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub, or mute the thread.
I created a psutil branch using GetLogicalProcessorInformation (not GetLogicalProcessorInformationEx) to determine both logical and physical CPUs: #1257 @twisniewski78 / @robbuckley : can you try it?
If you don't have Visual Studio I can send you a .whl file for Python 2.7 32 bit.
api-changean existing public API changed, was deprecated or removedbugtypecompatibilityworking installs or working code have to changewindowsplatform : Windows specific
Activity
giampaolo commentedon Sep 22, 2016
Sorry for such a big delay in responding. Can you provide more info about what kind of processors are these? Otherwise I really have no idea what kind of alternative API we could use.
twisniewski78 commentedon Sep 22, 2016
I have eight Xeons E7-2890 v2 with 15 cores each. My first guess would be NUMA architecture and Processor Group awareness rather then type of CPU. I was having the same issues on different system with 80 cores and different CPU model.
giampaolo commentedon Nov 25, 2016
Looking back at this: what does
len(psutil.cpu_times(percpu=True))return? 60 or 120?giampaolo commentedon Dec 1, 2016
The problem may be here:
psutil/psutil/_psutil_windows.c
Line 582 in 6c3e3e1
As per:
https://msdn.microsoft.com/en-us/library/windows/desktop/ms686694(v=vs.85).aspx
...if
(ptr->Relationship == RelationNumaNode)we may have to increment the counter by1Still, that would not match
len(psutil.cpu_percent(interval=1, percpu=True))which according to your report would keep returning half the cores.cpu_times(percpu=True)internally relies ondwNumberOfProcessors:psutil/psutil/_psutil_windows.c
Line 980 in 6c3e3e1
...which should be "correct", so I'm really not sure what to think.
twisniewski78 commentedon Dec 2, 2016
twisniewski78 commentedon Dec 2, 2016
giampaolo commentedon Dec 2, 2016
Indeed MS doc states:
It looks like GetLogicalProcessorInformationEx should give us what we want:
giampaolo commentedon Dec 2, 2016
Main problem is that I don't have the right hardware to test this against.
giampaolo commentedon Dec 2, 2016
Note:
os.cpu_count()on Python 3 relies onGetSystemInfo/dwNumberOfProcessorsso it has the same problem.twisniewski78 commentedon Dec 2, 2016
FJplant commentedon Dec 3, 2016
giampaolo commentedon Dec 3, 2016
It is (still investigating and not fixed).
FJplant commentedon Dec 3, 2016
14 remaining items
giampaolo commentedon May 16, 2017
OK, so can you please file an issue on http://bugs.python.org/?
robbuckley commentedon Jun 6, 2017
http://bugs.python.org/issue30581 raised
giampaolo commentedon Mar 28, 2018
Also related: https://bugs.python.org/issue33166
giampaolo commentedon Mar 28, 2018
I created a psutil branch using
GetLogicalProcessorInformation(notGetLogicalProcessorInformationEx) to determine both logical and physical CPUs:#1257
@twisniewski78 / @robbuckley : can you try it?
If you don't have Visual Studio I can send you a .whl file for Python 2.7 32 bit.
twisniewski78 commentedon Mar 28, 2018
Sadly I have no longer access to this environment or anything like it.
giampaolo commentedon Apr 13, 2018
OK, this should finally be fixed as of #1257.
giampaolo commentedon Oct 20, 2018
Closing out as fixed.