Ben Chuanlong Du's Blog

It is never too late to learn.

Get the Number of Cores in macOS

Using Shell Command

In [ ]:
sysctl hw.physicalcpu hw.logicalcpu

Using Python

In [2]:
import os

os.cpu_count()
Out[2]:
16
In [1]:
import multiprocessing as mp

mp.cpu_count()
Out[1]:
16
In [ ]:

Comments