Skip to content

Tests test_theil_sen_parallel and test_multi_output_classification_partial_fit_parallelism hang on Windows #12263

Closed

Description

@oleksandr-pavlyk

Description

Install scikit-learn 0.20.0 on Windows as follows:

conda create -n hang python=3.6.5
pip install scikit-learn==0.20.0
pip install pytest

Steps/Code to Reproduce

The following two individual test runs hang (never finish, and remain uninterruptable):

pytest -v --pyarg sklearn.tests.test_multioutput::test_multi_output_classification_partial_fit_parallelism
pytest -v --pyarg sklearn.linear_model.tests.test_theil_sen::test_theil_sen_parallel

Expected Results

Expecting them to pass as they do on Linux, or skipped in the distribution

Actual Results

Tests hang in both pip installed scikit-learn, as well in scikit-learn installed via conda itself.

Reproduced on "Windows Server 2012 R2 Standard".

Versions

>pip list
Package        Version
-------------- ---------
atomicwrites   1.2.1
attrs          18.2.0
certifi        2018.8.24
colorama       0.3.9
more-itertools 4.3.0
numpy          1.15.2
pip            10.0.1
pluggy         0.7.1
py             1.6.0
pytest         3.8.2
scikit-learn   0.20.0
scipy          1.1.0
setuptools     40.2.0
six            1.11.0
wheel          0.31.1
wincertstore   0.2

@ogrisel

Activity

  1. amueller commented on Oct 3, 2018

    @amueller
    Member

    Thank you for reporting! That's not great :-/

  2. added this to the 0.20.1 milestone on Oct 4, 2018
  3. tomMoral commented on Oct 5, 2018

    @tomMoral
    Contributor

    Could you also install pytest-timeout in your env and add the option -s --timeout=10 to your call to pytest. This way we will have more info on why this is stucked.

    It is weird that the test passes on appveyor if you see a deterministic failure on your machine.

  4. oleksandr-pavlyk commented on Oct 5, 2018

    @oleksandr-pavlyk
    ContributorAuthor

    Here is what I see:

    >pytest -s --timeout=10 -v --pyarg sklearn.linear_model.tests.test_theil_sen::test_theil_sen_parallel
    
    Exception in thread QueueManagerThread:
    
      File "<<elided>>\lib\site-packages\sklearn\externals\joblib\externals\loky\process_executor.py", line 617, in _queue_management_worker
        ready = wait(readers + worker_sentinels)
      File "<<elided>>\lib\multiprocessing\connection.py", line 859, in wait
      File "<<elided>>\lib\multiprocessing\connection.py", line 791, in _exhaustive_wait
        res = _winapi.WaitForMultipleObjects(L, False, timeout)
    ValueError: need at most 63 handles, got a sequence of length 129
    
    << lots of warnings suppressed >>
    
    +++++++++++++++++++++++++++++++++++ Timeout ++++++++++++++++++++++++++++++++++++
    
    ~~~~~~~~~~~~~~~~~~~~~~ Stack of QueueFeederThread (22640) ~~~~~~~~~~~~~~~~~~~~~~
    
      File "<<elided>>\lib\site-packages\sklearn\externals\joblib\externals\loky\backend\queues.py", line 138, in _feed
        nwait()
      File "<<elided>>\lib\threading.py", line 295, in wait
        waiter.acquire()
    
    ~~~~~~~~~~~~~~~~~~~~~~~~~ Stack of MainThread (24148) ~~~~~~~~~~~~~~~~~~~~~~~~~~
    
        testfunction(**testargs)
      File "<elided>\lib\site-packages\sklearn\linear_model\tests\test_theil_sen.py", line 267, in test_theil_sen_parallel
        max_subpopulation=2e3).fit(X, y)
      File "<elided>\site-packages\sklearn\linear_model\theil_sen.py", line 390, in fit
        for job in range(n_jobs))
      File "<<elided>>\lib\site-packages\sklearn\externals\joblib\parallel.py", line 996, in __call__
        self.retrieve()
      File "<<elided>>\lib\site-packages\sklearn\externals\joblib\parallel.py", line 899, in retrieve
        self._output.extend(job.get(timeout=self.timeout))
      File "<<elided>>\lib\site-packages\sklearn\externals\joblib\_parallel_backends.py", line 517, in wrap_future_result
        return future.result(timeout=timeout)
      File "<<elided>>\lib\concurrent\futures\_base.py", line 427, in result
        self._condition.wait(timeout)
      File "<<elided>>\lib\threading.py", line 295, in wait
        waiter.acquire()
    
    +++++++++++++++++++++++++++++++++++ Timeout ++++++++++++++++++++++++++++++++++++
    
    
  5. tomMoral commented on Oct 5, 2018

    @tomMoral
    Contributor

    It looks like you are missing a part of the trace in QueueManagerThread.
    Can you confirm that we can see all the trace or update it? (the first line should show the _queue_management_worker function first.)

  6. oleksandr-pavlyk commented on Oct 5, 2018

    @oleksandr-pavlyk
    ContributorAuthor

    @tomMoral Yes, my bad. I have updated the earlier comment to include the said line.

  7. tomMoral commented on Oct 5, 2018

    @tomMoral
    Contributor

    How many workers do you have here? Are you on a server with more than 127 cores?

  8. oleksandr-pavlyk commented on Oct 5, 2018

    @oleksandr-pavlyk
    ContributorAuthor

    The machine has Intel Xeon E5-2630 v3, with 2 sockets, 8 cores per socket, HT: 2. The task manager reports 16 cores, and 32 logical cores.

    When the test run hangs I do indeed see over 100 python processes in the task manager.

  9. jnothman commented on Nov 11, 2018

    @jnothman
    Member

    @oleksandr-pavlyk could you clarify whether this is resolved in master after c81e255?

  10. ogrisel commented on Nov 12, 2018

    @ogrisel
    Member

    I am starting a rackspace VM under windows to give it a try.

  11. ogrisel commented on Nov 12, 2018

    @ogrisel
    Member

    I have tried on a big Dual Intel Xeon E5-2660 v3 running Windows 2012 and scikit-learn 0.20.0 installed from pip in a dedicated conda env exactly as reported by @oleksandr-pavlyk and I could not reproduce the hangs. I repeated the pytest commands more than 20 times and each completed successfully in less than 2s. And I could see in the task manager than many cores were used. I also launched the full test suite successfully.

    I tried also to build scikit-learn master and launch the full test suite twice and it completed without any hang. There are failing doctests under windows but this is expected (the way the default dtype of integer arrays is printed in doctest output is not necessarily always consistent with the output under other platforms but this is harmless).

  12. oleksandr-pavlyk commented on Nov 12, 2018

    @oleksandr-pavlyk
    ContributorAuthor

    @ogrisel @jnothman Please allow me a moment to build it and run the test. I would report in about one hour (expected build + test run time on our server)

  13. oleksandr-pavlyk commented on Nov 12, 2018

    @oleksandr-pavlyk
    ContributorAuthor

    I can still see the hang with a local build from current master (4e81949).

    Upon execution of

    pytest -v --pyarg sklearn.tests.test_multioutput::test_multi_output_classification_partial_fit_parallelism
    

    There are 130 idle Python processes shown in task manager and the execution never terminates.

    Pressing Ctrl+C terminates all 130 processes, which is an improvement over an earlier version of joblib.

    Is there a way for me to access prebuilt wheels, or other binaries that you used to check whether the problem is fixed?

    Thanks!

  14. ogrisel commented on Nov 13, 2018

    @ogrisel
    Member

    If you built the master branch then the problem is still there. This is weird because I could not reproduce the issue, neither on 0.20.0 nor on master.

    Is there a way for me to access prebuilt wheels, or other binaries that you used to check whether the problem is fixed?

    Our CI uploads the wheels built on the master branch for 64 bit Python 3.7 and 32 bit Python 2.7 on the following rackspace blob storage:
    http://bc1c050a9b3a9f5bf3f5-965058070168eb2f1b8f5a23def30e14.r96.cf2.rackcdn.com/

    But they should yield the same result as the one you observed by building the master branch yourself.

  15. oleksandr-pavlyk commented on Nov 14, 2018

    @oleksandr-pavlyk
    ContributorAuthor

    Thanks @ogrisel . I downloaded and installed scikit_learn-0.21.dev0+20181114100605-cp37-cp37m-win_amd64.whl and can still reproduce the hang.

  16. 22 remaining items

  17. oleksandr-pavlyk commented on Apr 11, 2019

    @oleksandr-pavlyk
    ContributorAuthor

    We got bit by another one of these parallel tests, namely sklearn/decomposition/tests/test_dict_learning.py::test_dict_learning_reconstruction_parallel.

    At the same time, the test sklearn/decomposition/tests/test_dict_learning.py::test_sparse_coder_parallel_mmap runs fine.

    The difference between them is that the hanging one sets n_jobs=-1, while the working one is explicit n_jobs=2.

    If you think it is a good idea to be explicit about the number of jobs in test suite (say n_job 4 or less), I would open a PR. Please let me know.

  18. jnothman commented on Apr 14, 2019

    @jnothman
    Member
  19. modified the milestones: 0.21.1, 0.21.2 on May 18, 2019
  20. modified the milestones: 0.21.2, 0.21.3 on May 25, 2019
  21. modified the milestones: 0.21.3, 0.23 on Oct 31, 2019
  22. adrinjalali commented on Apr 20, 2020

    @adrinjalali
    Member

    It seems this issue is fixed? Closing, please feel free to reopen if it's still an issue.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions