Skip to content

torchvision sets multiprocessing start_method #544

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
ssnl opened this issue Jul 11, 2018 · 5 comments
Closed

torchvision sets multiprocessing start_method #544

ssnl opened this issue Jul 11, 2018 · 5 comments

Comments

@ssnl
Copy link
Contributor

ssnl commented Jul 11, 2018

test git:(stft_fft) ✗ python
Python 3.6.5 |Anaconda, Inc.| (default, Apr 29 2018, 16:14:56)
[GCC 7.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import multiprocessing as mp
>>> mp.set_start_method('spawn')
>>>test git:(stft_fft) ✗ python
Python 3.6.5 |Anaconda, Inc.| (default, Apr 29 2018, 16:14:56)
[GCC 7.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import torchvision
>>> import multiprocessing as mp
>>> mp.set_start_method('spawn')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/ssnl/miniconda3/lib/python3.6/multiprocessing/context.py", line 242, in set_start_method
    raise RuntimeError('context has already been set')
RuntimeError: context has already been set

I used builtin mp. Same thing happens for torch.mp.

@fmassa
Copy link
Member

fmassa commented Jul 13, 2018

This is very weird!

I did some debugging, and this is actually a problem with tqdm

from tqdm import tqdm
import multiprocessing as mp
mp.set_start_method('spawn')

raises

---------------------------------------------------------------------------
RuntimeError                              Traceback (most recent call last)
<ipython-input-3-36f1a10db7c0> in <module>()
----> 1 mp.set_start_method('spawn')

~/.conda/envs/detectron_v2/lib/python3.6/multiprocessing/context.py in set_start_method(self, method, force)
    240     def set_start_method(self, method, force=False):
    241         if self._actual_context is not None and not force:
--> 242             raise RuntimeError('context has already been set')
    243         if method is None and force:
    244             self._actual_context = None

RuntimeError: context has already been set

If this is a blocker we might want to consider removing tqdm from torchvision

@ssnl
Copy link
Contributor Author

ssnl commented Jul 13, 2018 via email

@fmassa
Copy link
Member

fmassa commented Feb 13, 2019

This has been fixed since version 4.29.0 of tqdm https://github.com/tqdm/tqdm/releases

@fmassa fmassa closed this as completed Feb 13, 2019
@wj1017090777
Copy link

After the update, I still have this problem

@fmassa
Copy link
Member

fmassa commented Nov 6, 2020

As Simon mentioned above, many libraries set the multiprocessing start method.
torchvision doesn't directly use any of those, and if you are facing this problem it might be good to isolate which library is doing this in torchvision.

rajveerb pushed a commit to rajveerb/vision that referenced this issue Nov 30, 2023
* [RetinaNet] Changed the default lr to match adam optimizer

* [RetinaNet] fixes to the onnx conversion script

* [RetinaNet] Cleaned up CocoEvaluator implementation

* [RetinaNet] Bumped pycocotools version to 2.0.4

Fixes mlcommons/training/pytorch#540
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants