Is there a method to find out how many CPUs there are?

Asked 2 years ago, Updated 2 years ago, 110 views

Is there a way to find out how many CPUs are in your computer?

I hope it's a method that runs as t(1) because I have to check it quickly and move on.

python cpu system-information

2022-09-22 22:15

1 Answers

If the number of CPUs is unknown, return None

import os
os.cpu_count()

Not ImplementedError may also occur

import multiprocessing
multiprocessing.cpu_count()


2022-09-22 22:15

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.