open-mmlab / open-mmlab/mmengine
AttributeError: module 'torch.distributed' has no attribute 'ReduceOp'
Open
Nobody has claimed this yet.
bug
- Dominant language
- Python
- Stars
- 1.5k
- Forks
- 464
- PR merge metrics
- No merged PRs in 30d
Description
Prerequisite
- I have searched Issues and Discussions but cannot get the expected help.
- The bug has not been fixed in the latest version(https://github.com/open-mmlab/mmengine).
Environment
(mmseg) lengyela@MAC-RXKFF69F0X mmsegmentation % conda list
# packages in environment at /Users/lengyela/miniconda3/envs/mmseg:
#
# Name Version Build Channel
addict 2.4.0 pypi_0 pypi
aliyun-python-sdk-core 2.14.0 pypi_0 pypi
aliyun-python-sdk-kms 2.16.2 pypi_0 pypi
brotli-python 1.1.0 py39hb198ff7_1 conda-forge
bzip2 1.0.8 h93a5062_5 conda-forge
ca-certificates 2024.2.2 hf0a4a13_0 conda-forge
certifi 2024.2.2 pyhd8ed1ab_0 conda-forge
cffi 1.16.0 pypi_0 pypi
charset-normalizer 3.3.2 pyhd8ed1ab_0 conda-forge
click 8.1.7 pypi_0 pypi
colorama 0.4.6 pypi_0 pypi
contourpy 1.2.0 pypi_0 pypi
crcmod 1.7 pypi_0 pypi
cryptography 42.0.5 pypi_0 pypi
cycler 0.12.1 pypi_0 pypi
filelock 3.13.1 pyhd8ed1ab_0 conda-forge
fonttools 4.49.0 pypi_0 pypi
freetype 2.12.1 hadb7bae_2 conda-forge
fsspec 2024.2.0 pyhca7485f_0 conda-forge
idna 3.6 pyhd8ed1ab_0 conda-forge
importlib-metadata 7.0.1 pypi_0 pypi
importlib-resources 6.1.2 pypi_0 pypi
jinja2 3.1.3 pyhd8ed1ab_0 conda-forge
jmespath 0.10.0 pypi_0 pypi
kiwisolver 1.4.5 pypi_0 pypi
lcms2 2.16 ha0e7c42_0 conda-forge
lerc 4.0.0 h9a09cb3_0 conda-forge
libabseil 20230802.1 cxx17_h13dd4ca_0 conda-forge
libblas 3.9.0 21_osxarm64_openblas conda-forge
libcblas 3.9.0 21_osxarm64_openblas conda-forge
libcxx 16.0.6 h4653b0c_0 conda-forge
libdeflate 1.19 hb547adb_0 conda-forge
libexpat 2.5.0 hb7217d7_1 conda-forge
libffi 3.4.2 h3422bc3_5 conda-forge
libgfortran 5.0.0 13_2_0_hd922786_3 conda-forge
libgfortran5 13.2.0 hf226fd6_3 conda-forge
libjpeg-turbo 3.0.0 hb547adb_1 conda-forge
liblapack 3.9.0 21_osxarm64_openblas conda-forge
libopenblas 0.3.26 openmp_h6c19121_0 conda-forge
libpng 1.6.42 h091b4b1_0 conda-forge
libprotobuf 4.24.4 h810fc01_0 conda-forge
libsqlite 3.45.1 h091b4b1_0 conda-forge
libtiff 4.6.0 ha8a6c65_2 conda-forge
libuv 1.47.0 h93a5062_0 conda-forge
libwebp-base 1.3.2 hb547adb_0 conda-forge
libxcb 1.15 hf346824_0 conda-forge
libzlib 1.2.13 h53f4e23_5 conda-forge
llvm-openmp 17.0.6 hcd81f8e_0 conda-forge
markdown 3.5.2 pypi_0 pypi
markdown-it-py 3.0.0 pypi_0 pypi
markupsafe 2.1.5 py39h17cfd9d_0 conda-forge
matplotlib 3.8.3 pypi_0 pypi
mdurl 0.1.2 pypi_0 pypi
mmcv-lite 2.1.0 pypi_0 pypi
mmengine 0.10.3 pypi_0 pypi
mmsegmentation 1.2.2 dev_0 <develop>
model-index 0.1.11 pypi_0 pypi
mpmath 1.3.0 pyhd8ed1ab_0 conda-forge
ncurses 6.4 h463b476_2 conda-forge
networkx 3.2.1 pyhd8ed1ab_0 conda-forge
nomkl 1.0 h5ca1d4c_0 conda-forge
numpy 1.26.4 py39h7aa2656_0 conda-forge
opencv-python 4.9.0.80 pypi_0 pypi
opendatalab 0.0.10 pypi_0 pypi
openjpeg 2.5.0 h4c1507b_3 conda-forge
openmim 0.3.9 pypi_0 pypi
openssl 3.2.1 h0d3ecfb_0 conda-forge
openxlab 0.0.34 pypi_0 pypi
ordered-set 4.1.0 pypi_0 pypi
oss2 2.17.0 pypi_0 pypi
packaging 23.2 pypi_0 pypi
pandas 2.2.1 pypi_0 pypi
pillow 10.2.0 py39h755f0b7_0 conda-forge
pip 24.0 pyhd8ed1ab_0 conda-forge
platformdirs 4.2.0 pypi_0 pypi
prettytable 3.10.0 pypi_0 pypi
pthread-stubs 0.4 h27ca646_1001 conda-forge
pycparser 2.21 pypi_0 pypi
pycryptodome 3.20.0 pypi_0 pypi
pygments 2.17.2 pypi_0 pypi
pyparsing 3.1.1 pypi_0 pypi
pysocks 1.7.1 pyha2e5f31_6 conda-forge
python 3.9.18 hd7ebdb9_1_cpython conda-forge
python-dateutil 2.8.2 pypi_0 pypi
python_abi 3.9 4_cp39 conda-forge
pytorch 2.1.0 cpu_generic_py39h4a6bf10_0 conda-forge
pytz 2023.4 pypi_0 pypi
pyyaml 6.0.1 py39h0f82c59_1 conda-forge
readline 8.2 h92ec313_1 conda-forge
requests 2.28.2 pypi_0 pypi
rich 13.4.2 pypi_0 pypi
scipy 1.12.0 pypi_0 pypi
setuptools 60.2.0 pypi_0 pypi
six 1.16.0 pypi_0 pypi
sleef 3.5.1 h156473d_2 conda-forge
sympy 1.12 pyh04b8f61_3 conda-forge
tabulate 0.9.0 pypi_0 pypi
termcolor 2.4.0 pypi_0 pypi
tk 8.6.13 h5083fa2_1 conda-forge
tomli 2.0.1 pypi_0 pypi
torchvision 0.16.1 cpu_py39hdcc7767_2 conda-forge
tqdm 4.65.2 pypi_0 pypi
typing_extensions 4.9.0 pyha770c72_0 conda-forge
tzdata 2024.1 pypi_0 pypi
urllib3 1.26.18 pypi_0 pypi
wcwidth 0.2.13 pypi_0 pypi
wheel 0.42.0 pyhd8ed1ab_0 conda-forge
xorg-libxau 1.0.11 hb547adb_0 conda-forge
xorg-libxdmcp 1.1.3 h27ca646_0 conda-forge
xz 5.2.6 h57fd34a_0 conda-forge
yaml 0.2.5 h3422bc3_2 conda-forge
yapf 0.40.2 pypi_0 pypi
zipp 3.17.0 pypi_0 pypi
zstd 1.5.5 h4f39d0f_0 conda-forge
Reproduces the problem - code sample
from mmengine.dist import all_reduce
Reproduces the problem - command or script
(mmseg) lengyela@MAC-RXKFF69F0X mmsegmentation % python -c "from mmengine.utils.dl_utils import collect_env; print(collect_env())"
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/Users/lengyela/miniconda3/envs/mmseg/lib/python3.9/site-packages/mmengine/utils/dl_utils/__init__.py", line 8, in <module>
from .time_counter import TimeCounter
File "/Users/lengyela/miniconda3/envs/mmseg/lib/python3.9/site-packages/mmengine/utils/dl_utils/time_counter.py", line 8, in <module>
from mmengine.dist.utils import master_only
File "/Users/lengyela/miniconda3/envs/mmseg/lib/python3.9/site-packages/mmengine/dist/__init__.py", line 2, in <module>
from .dist import (all_gather_object, all_reduce, all_gather, all_reduce_dict,
File "/Users/lengyela/miniconda3/envs/mmseg/lib/python3.9/site-packages/mmengine/dist/dist.py", line 26, in <module>
def _get_reduce_op(name: str) -> torch_dist.ReduceOp:
AttributeError: module 'torch.distributed' has no attribute 'ReduceOp'
Reproduces the problem - error message
(mmseg) lengyela@MAC-RXKFF69F0X mmsegmentation % python -c "from mmengine.utils.dl_utils import collect_env; print(collect_env())"
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/Users/lengyela/miniconda3/envs/mmseg/lib/python3.9/site-packages/mmengine/utils/dl_utils/__init__.py", line 8, in <module>
from .time_counter import TimeCounter
File "/Users/lengyela/miniconda3/envs/mmseg/lib/python3.9/site-packages/mmengine/utils/dl_utils/time_counter.py", line 8, in <module>
from mmengine.dist.utils import master_only
File "/Users/lengyela/miniconda3/envs/mmseg/lib/python3.9/site-packages/mmengine/dist/__init__.py", line 2, in <module>
from .dist import (all_gather_object, all_reduce, all_gather, all_reduce_dict,
File "/Users/lengyela/miniconda3/envs/mmseg/lib/python3.9/site-packages/mmengine/dist/dist.py", line 26, in <module>
def _get_reduce_op(name: str) -> torch_dist.ReduceOp:
AttributeError: module 'torch.distributed' has no attribute 'ReduceOp'
Additional information
I have followed the CPU-only install instructions, but mmengine is not running correctly on MacOS.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with mmengine/dist/dist.py at the _get_reduce_op definition and reproduce the failure with the reported collect_env command. Compare the behavior of the installed CPU-only PyTorch environment with the distributed utility's expectations; done means importing mmengine.dist and running collect_env works on the reported macOS setup.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python, pytorch
- Domain
- distributed-systems, machine-learning
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100