Judy T Raj
Judy T Raj

Reputation: 1844

Is there a pytorch method to check the number of cpus?

I can use this torch.cuda.device_count() to check the number of GPUs. I was wondering if there was something equivalent to check the number of CPUs.

Upvotes: 17

Views: 14450

Answers (2)

simon
simon

Reputation: 2821

just use this :

os.cpu_count()

Upvotes: 18

ssh
ssh

Reputation: 167

At present pytorch doesn't support multiple cpu cluster in DistributedDataParallel implementation. So, I am assuming you mean number of cpu cores.

There's no direct equivalent for the gpu count method but you can get the number of threads which are available for computation in pytorch by using

torch.get_num_threads()

Upvotes: 6

Related Questions