+1 vote
in Programming Languages by (8.9k points)
Is there any Python function to find how many CPUs are there on my computer?

1 Answer

+2 votes
by (56.8k points)
selected by
 
Best answer

You can use either multiprocessing or os module of Python to find the number of CPUs on a computer. 

Here is an example: 

>>> import multiprocessing

>>> multiprocessing.cpu_count()

8

>>> import os

>>> os.cpu_count()

8

>>> 

The number shown above is the number of logical CPUs available on the system. If hyperthreading is enabled on your CPU, the count will also include virtual cores. 


...