Atul Khera
Atul Khera

Reputation: 91

how many 'CPU' cores does google colab assigns when I keep n_jobs=8, is there any way to check that?

I am running Regression tasks in Google colab with GridSearhCV. In parameters I keep n_jobs=8, when I keep it to -1 (to use all possible cores) it uses only 2 cores, so I am assuming that there is a limit there on server end if n_jobs=-1, so i would like to know that how to check how many cores are actually getting used.

Upvotes: 9

Views: 23280

Answers (2)

Shayan Abbasi
Shayan Abbasi

Reputation: 374

If you use the code below, you will see that the multiprocessor in Google colab has 2 cores:

import multiprocessing

cores = multiprocessing.cpu_count() # Count the number of cores in a computer
cores

Upvotes: 21

Shayan Abbasi
Shayan Abbasi

Reputation: 374

That is a question that I had too. I've put n_job = 100 in Colab and I've got:

[Parallel(n_jobs=100)]: Using backend LokyBackend with 100 concurrent workers.

This is a surprising because google colab only gives you 2 processors. However, you can always use your own CPU/GPU on colab.

Upvotes: 2

Related Questions