open-mmlab / mmcv

OpenMMLab Computer Vision Foundation
https://mmcv.readthedocs.io/en/latest/
Apache License 2.0
5.91k stars 1.65k forks source link

[Bug] ImportError: cannot import name 'revert_sync_batchnorm' from 'mmcv.cnn.utils' (/home/ubuntu/miniconda3/envs/LightCD/lib/python3.10/site-packages/mmcv/cnn/utils/__init__.py) 但是根据重新安装mmcv-full==1.7.1则会持续报错 pip install mmcv-full==1.7.1 -f https://download.openmmlab.com/mmcv/dist/cu121/torch2.1/index.html ERROR: Failed building wheel for mmcv-full Running setup.py clean for mmcv-full Failed to build mmcv-full ERROR: Could not build wheels for mmcv-full, which is required to install pyproject.toml-based projects #3005

Closed HZWXW371 closed 10 months ago

HZWXW371 commented 11 months ago

Prerequisite

Environment

cuda 12.1 torch 2.1

Reproduces the problem - code sample

pip install mmcv-full==1.7.1 -f https://download.openmmlab.com/mmcv/dist/cu121/torch2.1/index.html ERROR: Failed building wheel for mmcv-full Running setup.py clean for mmcv-full Failed to build mmcv-full ERROR: Could not build wheels for mmcv-full, which is required to install pyproject.toml-based projects

python tools/train.py configs/lightcdnet/lightcdnet_s_256x256_40k_levircd.py --work-dir ./exp/lightcdnet_s_levir_workdir --gpu-id 0 --seed 602 ImportError: cannot import name 'revert_sync_batchnorm' from 'mmcv.cnn.utils' (/home/ubuntu/miniconda3/envs/LightCD/lib/python3.10/site-packages/mmcv/cnn/utils/init.py)

Reproduces the problem - command or script

python tools/train.py configs/lightcdnet/lightcdnet_s_256x256_40k_levircd.py --work-dir ./exp/lightcdnet_s_levir_workdir --gpu-id 0 --seed 602

pip install mmcv-full==1.7.1 -f https://download.openmmlab.com/mmcv/dist/cu121/torch2.1/index.html

Reproduces the problem - error message

ERROR: Failed building wheel for mmcv-full Running setup.py clean for mmcv-full Failed to build mmcv-full ERROR: Could not build wheels for mmcv-full, which is required to install pyproject.toml-based projects

ImportError: cannot import name 'revert_sync_batchnorm' from 'mmcv.cnn.utils' (/home/ubuntu/miniconda3/envs/LightCD/lib/python3.10/site-packages/mmcv/cnn/utils/init.py)

Additional information

正常安装mmcv-full顺利使用MMCV运行

zhouzaida commented 11 months ago

Hi, we have not provided the pre-built packages for pytorch2.1.0 when the mmcv version is less than 2.0.0. And we will provide them soon. You can also try to build it from source (https://mmcv.readthedocs.io/en/1.x/get_started/build.html#build-on-linux).

zhouzaida commented 10 months ago

Hi @HZWXW371 , you could try to install mmcv-full 1.7.2 with the following commands:

pip install mmcv-full==1.7.2 -f https://download.openmmlab.com/mmcv/dist/cu121/torch2.1/index.html

or

mim install mmcv-full==1.7.2