Monday, March 16, 2015

Python to determine number of CPUs

multiprocessing.cpu_count() return the number of CPUs in the system.

Example code, run on Raspberry Pi 2 with quad-core ARM Cortex-A7 CPU:


import sys
import multiprocessing

print("sys.version:")
print(sys.version + "\n")

numOfCPU = multiprocessing.cpu_count()
print("Number of CPU: " + str(numOfCPU))


No comments: