Python multiprocessing.cpu_count() returns '1' on 4-core Nvidia Jetson TK1

On Linux systems multiprocessing.cpu_count() relies on a sysconf (_SC_NPROCESSORS_ONLN) call, which returns the number of online CPUs in contrast to sysconf (_SC_NPROCESSORS_CONF) which returns the number of configured CPUs.

The values might differ in systems with advanced CPU power management functionality that sets CPU cores offline to save energy or with similar dynamic CPU activation functionality.


The documentation for os.cpu_count() (which declares that it returns the total number of CPUS, not the number of usable CPUs) provides a means to count usable CPUs:

len(os.sched_getaffinity(0))

see https://docs.python.org/3/library/os.html#os.cpu_count