Multiprocessing import error

– EDIT: it seems a python issue or related. dont know how. from multiprocessing.util import register_after_fork is a python module that is being imported in not sure why this issue raises because from multiprocessing.util import register_after_fork works fine in python. almost certain that it has something to do with the installation. tried code on different virtual env. torch multiprocessing works fine… creating a new new virtual env. and installing pytorch in it solved the issue.

code was working fine.
did a script where i used import torch.multiprocessing as mp. running the script throws the error bellow.
now, running any script, without even multiprocessing, throws the same error.
simply import torch throws the error.
doing import torch in python or ipython interpreter is fine.
any idea?
pytorch 1.9.0
Python 3.7.10 (default, Feb 26 2021, 18:47:35) [GCC 7.3.0] :: Anaconda, Inc. on linux


Traceback (most recent call last):
  File "", line 3, in <module>
    import torch
  File "x/lib/python3.7/site-packages/torch/", line 688, in <module>
    from torch import multiprocessing as multiprocessing
  File "x/lib/python3.7/site-packages/torch/multiprocessing/", line 18, in <module>
    from .reductions import init_reductions
  File "x/lib/python3.7/site-packages/torch/multiprocessing/", line 7, in <module>
    from multiprocessing.util import register_after_fork
ModuleNotFoundError: No module named 'multiprocessing.util'; 'multiprocessing' is not a package

@sbelharbi The module can not be found. I would try a clean install.

yeah. i am making a new install…
installing pytroch in a fresh virtual env. solved the issue.

Had the same issue, I deleted the $HOME.cache/torch location from my Mac and it solved the issue.

rm -rf .cache/torch