Python's os.cpu_count()
returns the wrong number of cores on my Mac.
macOS system report:
Model Name: MacBook Pro
Model Identifier: MacBookPro14,3
Processor Name: Quad-Core Intel Core i7
Processor Speed: 2.9 GHz
Number of Processors: 1
Total Number of Cores: 4
Yet os.cpu_count()
returns 8 .
Is that a bug or I'm missing something?
This is Python 3.8.6; I also checked the Python v2 that comes with the system (using multiprocessing.cpu_count()
) and the result is the same.
os.cpu_count() returns the number of logical processors within the machines CPU, also known as threads. If it returns 8 then your machine has 8 threads, not cores.
os.cpu_count()
means threads not cores.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.