Skip to content
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

您好,遇到了mmcv的奇怪报错。。。 #12

Closed
EmarkZOU opened this issue Aug 14, 2024 · 0 comments
Closed

您好,遇到了mmcv的奇怪报错。。。 #12

EmarkZOU opened this issue Aug 14, 2024 · 0 comments

Comments

@EmarkZOU
Copy link

感谢您非常优秀的工作,但是在复现过程中,我遇到了下列问题:

首先,按照文档安装,会自动安装mmcv-full==1.7.2版本

pip install -U openmim
mim install "mmcv-full<2.0.0"

运行代码后报错:

AssertionError: MMCV==1.7.0 is used but incompatible. Please install mmcv>=2.0.0rc4, <2.2.0.

错误原因在于该版本不兼容,至少安装2.0.0rc4版本的,重新安装

pip install mmcv-full==2.0.0rc4

运行代码后,再次报错:

Cannot import name 'Config' from 'mmcv'

错误原因在于mmcv在2.0.x版本之后,Config 等一些训练相关的模块被删除了

(1)删除了以下组件:

(2)新增了 [mmcv.transforms](https://github.com/open-mmlab/mmcv/tree/main/mmcv/transforms) 数据变换模块

(3)在 PR [#2235](open-mmlab/mmcv#2235) 中将包名 mmcv 重命名为 mmcv-litemmcv-full 重命名为 mmcv。此外,将环境变量 MMCV_WITH_OPS 的默认值从 0 改为 1

这也能理解,为什么配置mmcv环境时的混乱不堪了

import mmcv
import torch

from mmengine.config import Config, DictAction
from mmcv.cnn import fuse_conv_bn
from mmengine.runner import (get_dist_info, init_dist, load_checkpoint,
                         wrap_fp16_model)

from mmdet.apis import multi_gpu_test, single_gpu_test
from mmdet.datasets import (build_dataloader, build_dataset,
                            replace_ImageToTensor)
from mmdet.models import build_detector
from mmdet.utils import (build_ddp, build_dp, compat_cfg, get_device,
                         replace_cfg_vals, setup_multi_processes,
                         update_data_root)

只能将报错的代码,逐步替换为2.0后版本的模块

https://stackoverflow.com/questions/75988459/cannot-import-name-config-from-mmcv-unknown-location

其中,报错内容:

ImportError: cannot import name 'Config' from 'mmcv'
ImportError: cannot import name 'get_dist_info' from 'mmengine.runner'
ImportError: cannot import name 'print_log' from 'mmcv'

未找到print_log出现位置

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant