Sunday, 20 December 2015

Python: Get number of cpus in system

Following methods are used to get number of cpus in your system.


Method
Description
multiprocessing.cpu_count()
Return number of cpus in the system
os.cpu_count()
Return number of cpus in the system

import multiprocessing
import os


if(__name__=="__main__"):
    print("Number Of CPUS : ", multiprocessing.cpu_count())
    print("Number Of CPUS : ", os.cpu_count())

Sample Output
Number Of CPUS :  8
Number Of CPUS :  8




Previous                                                 Next                                                 Home

No comments:

Post a Comment