glearn.device.get_num_cpu_threads#
- glearn.device.get_num_cpu_threads()#
Returns the number of available CPU processor threads.
- Returns:
- num_threadsint
Number of processor threads.
Notes
The returned value is not the total number of CPU threads. Rather, the number of available CPU threads that is allocated to the user is returned. For instance, if on a device with 8 threads, only 2 threads are allocated to a user, the return value of this function is 2.
Examples
Find the number of available CPU threads:
>>> from glearn.device import get_num_cpu_threads >>> get_num_cpu_threads() 2
Find the total number of CPU threads on the device (all may not be available/allocated to the user):
>>> # Method 1 >>> import os >>> os.cpu_count() 8 >>> # Method 2 >>> import multiprocessing >>> multiprocessing.cpu_count() 8