mmsegmentation icon indicating copy to clipboard operation
mmsegmentation copied to clipboard

ImportError: cannot import name 'revert_sync_batchnorm' from 'mmcv.cnn.utils'

Open IamMegatron2025 opened this issue 2 years ago • 8 comments

Hello~ When I run tools/train.py, it shows error:

  File "tools/train.py", line 12, in <module>
    from mmcv.cnn.utils import revert_sync_batchnorm
ImportError: cannot import name 'revert_sync_batchnorm' from 'mmcv.cnn.utils' (/xxxpy3.8/lib/python3.8/site-packages/mmcv/cnn/utils/__init__.py)

My envs are:

python3.8
torch==1.13.0
mmcv==2.0.0

How to fix it ? Looking forward to your reply.

IamMegatron2025 avatar Jul 19 '23 13:07 IamMegatron2025

I have the same error.

ChinWicky avatar Aug 03 '23 01:08 ChinWicky

same error

TaoBowoa180011 avatar Aug 17 '23 02:08 TaoBowoa180011

try:

mim uninstall mmcv

mim install mmcv-full

mim install mmcv==1.6.0

IamMegatron2025 avatar Aug 21 '23 09:08 IamMegatron2025

Did anyone find a solution for this error? Seems like the function is now present in mmengine.model

from mmengine.model import revert_sync_batchnorm

tejchemikala avatar Sep 10 '23 10:09 tejchemikala

same error

JimmyMa99 avatar Dec 09 '23 14:12 JimmyMa99

try lower version of mmcv

WJHash avatar Aug 06 '24 13:08 WJHash

in mmcv2.0.0 and higher version this error happens ,but when i install lower version,it turns out to :

Traceback (most recent call last): File "tools/train-deeplabv3plus.py", line 16, in from mmseg import version File "/home/dell/Software/Anaconda3/envs/openmmlabnew/lib/python3.8/site-packages/mmseg/init.py", line 61, in assert (mmcv_min_version <= mmcv_version < mmcv_max_version),
AssertionError: MMCV==1.7.2 is used but incompatible. Please install mmcv>=2.0.0rc4.

really confused,i think the train.py code should be edited

xuans29 avatar Aug 07 '24 07:08 xuans29