Skip to content

Possible regression in nested parallelism #12389

Closed

Description

@glemaitre

I think that we have a possible regression linked to the nested parallelism. Let's take the following minimum example:

import numpy as np                                                                   
from sklearn.ensemble import RandomForestClassifier                                  
from sklearn.model_selection import cross_val_score                                  
                                                                                     
X = np.random.randn(500000, 80)                                                      
y = np.random.randint(0, 2, 500000)                                                  
                                                                                     
clf = RandomForestClassifier(n_jobs=-1)                                                               
cross_val_score(clf, X, y, n_jobs=1) 

In 0.19.2, htop shows activity for all processors. In 0.20, a single core is active. Is it link to the heuristic to avoid to over-subscription?

Can anyone try to reproduce it? ping @tomMoral @ogrisel @pierreglaser

Activity

  1. jnothman commented on Oct 15, 2018

    @jnothman
    Member
  2. added this to the 0.20.1 milestone on Oct 15, 2018
  3. glemaitre commented on Oct 15, 2018

    @glemaitre
    MemberAuthor

    The opposite actually.

    #12289 was due to default setting n_jobs=-1 internally in joblib from what I understand in the bugfix.

  4. jeremiedbb commented on Oct 15, 2018

    @jeremiedbb
    Member

    It won't fix the bug, but in the meanwhile you can do that :)

    clf = RandomForestClassifier(n_jobs=1)                                                               
    cross_val_score(clf, X, y, n_jobs=-1) 
  5. glemaitre commented on Oct 15, 2018

    @glemaitre
    MemberAuthor

    I checked with joblib master by enabling the site version and the bug is still there.

    It won't fix the bug, but in the meanwhile you can still do

    Since this is just for a course on computer with 4 cores, it would be OK to do so. However, people with 48 cores computer will be a bit disappointed :)

  6. tomMoral commented on Oct 15, 2018

    @tomMoral
    Contributor

    This looks like an issue with SequentialBackend, which set by default SequentialBackend as a nested backend.... (see here).

    It should actually not set a nested backend when nesting level is 0, as this disable multithreading in this case. Nice catch, this should be fixed.

  7. tomMoral commented on Oct 16, 2018

    @tomMoral
    Contributor

    This should be fixed on the joblib master. Can you confirm?

  8. glemaitre commented on Oct 17, 2018

    @glemaitre
    MemberAuthor

    Yep. Everything is fine. Shall we close now or when we release 0.20.1 with the new vendored joblib?

  9. amueller commented on Oct 17, 2018

    @amueller
    Member

    we fix if it's closed in sklearn master usually...

  10. ogrisel commented on Nov 7, 2018

    @ogrisel
    Member

    This was fixed by merging joblib 0.13.0. I just checked on master and @glemaitre's code snippet causes all CPUs to be used at 100% as expected.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions