Talha Anwar
Talha Anwar

Reputation: 2949

Specify cores in n_jobs sklearn

Sklearn used n_jobs parameter in multiple functions. We can pass how many cores we want to use. For example 1 for one core and -1 for all cores. My system has six cores and I want to use [0,1,3,4] cores only. Is this possible?

Upvotes: 1

Views: 419

Answers (2)

Yahya
Yahya

Reputation: 14062

I've never tried nor heard about this possibility before, with scikit-learn.

Still, as scikit-learn uses joblib, it might be the right direction, for you to investigate, to start looking for how to implement your custom ParallelBackendBase, which is a helper abc that defines all methods a ParallelBackend must implement 1, 2, 3; you might be able to implement internally CPU Affinity to pin a process to a particular CPU core.

Nevertheless, it is purely experimental.

Upvotes: 1

9769953
9769953

Reputation: 12192

No, that is not possible: you can't specify specific cores, that is up to the system.

Upvotes: 0

Related Questions