mmdeploy: AttributeError: module 'mmcv' has no attribute 'Config'[Bug]

Checklist

  • I have searched related issues but cannot get the expected help.
  • 2. I have read the FAQ documentation but cannot get the expected help.
  • 3. The bug has not been fixed in the latest version.

Describe the bug

I’m trying to export a model to TensorRT using following command:

export LD_LIBRARY_PATH=/usr/local/cuda/lib64:/home/sorter/TensorRT-8.4.1.5/lib:/home/sorter/onnxruntime-linux-x64-1.8.1/lib
export PYTHONPATH=${PYTHONPATH}:/home/sorter/mmdeploy

python /home/sorter/mmdeploy/tools/deploy.py \
    'instance-seg_tensorrt-int8_static.py' \
    'rtmdet-ins_tiny_config.py' \
    'rtmdet-ins_tiny/epoch_300.pth' \
    'data/val/images/970000000001.0.jpg' \
    --test-img 'data/val/images/21.jpg' \
    --work-dir 'rtmdet_export/' \
    --log-level DEBUG\
    --show \
    --device cuda:0 \

But getting following error:

Traceback (most recent call last):
  File "/home/sorter/mmdeploy/tools/deploy.py", line 12, in <module>
    from mmdeploy.apis import (create_calib_input_data, extract_model,
  File "/home/sorter/mmdeploy/mmdeploy/__init__.py", line 4, in <module>
    from mmdeploy.utils import get_root_logger
  File "/home/sorter/mmdeploy/mmdeploy/utils/__init__.py", line 18, in <module>
    from .config_utils import (cfg_apply_marks, get_backend,
  File "/home/sorter/mmdeploy/mmdeploy/utils/config_utils.py", line 10, in <module>
    def load_config(*args) -> List[mmcv.Config]:
AttributeError: module 'mmcv' has no attribute 'Config'

Following instructions griven here. mmcv=2.0.0rc2

Reproduction

go to the mmdeploy folder

cd ${PATH_TO_MMDEPLOY}

download RTMDet-s checkpoint

wget -P checkpoint https://download.openmmlab.com/mmdetection/v3.0/rtmdet/rtmdet_s_8xb32-300e_coco/rtmdet_s_8xb32-300e_coco_20220905_161602-387a891e.pth

run the command to start model conversion

python tools/deploy.py
configs/mmdet/detection/detection_tensorrt_static-640x640.py
${PATH_TO_MMDET}/configs/rtmdet/rtmdet_s_8xb32-300e_coco.py
checkpoint/rtmdet_s_8xb32-300e_coco_20220905_161602-387a891e.pth
demo/resources/det.jpg
–work-dir ./work_dirs/rtmdet
–device cuda:0
–show

Environment

Traceback (most recent call last):
  File "tools/check_env.py", line 4, in <module>
    from mmcv.utils import get_git_hash
ImportError: cannot import name 'get_git_hash' from 'mmcv.utils' (/home/sorter/miniconda3/envs/openmmlab/lib/python3.8/site-packages/mmcv/utils/__init__.py)

Error traceback

No response

About this issue

  • Original URL
  • State: open
  • Created a year ago
  • Reactions: 2
  • Comments: 15

Most upvoted comments

in https://mmcv.readthedocs.io/zh_CN/latest/compatibility.html ,可以看到 mmcv.utils 的所有类(例如 Config 和 Registry)和大部分函数,删除于 PR #2217,只保留少数和 mmcv 相关的函数;大部分相关函数被移入到mmengine中了 so,you can try:

# import mmcv 
# mmcv.Config
import mmengine
mmengine.Config

@hanrui1sensetime it seems that mmcv-2 series made some changes to the definition of mmcv member variables? Where can I see the modified usage method or instructions about the modification image

I’m getting following error with import mmdeploy

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/sort/mmdeploy/mmdeploy/__init__.py", line 4, in <module>
    from mmdeploy.utils import get_root_logger
  File "/home/sort/mmdeploy/mmdeploy/utils/__init__.py", line 18, in <module>
    from .config_utils import (cfg_apply_marks, get_backend,
  File "/home/sort/mmdeploy/mmdeploy/utils/config_utils.py", line 10, in <module>
    def load_config(*args) -> List[mmcv.Config]:
AttributeError: module 'mmcv' has no attribute 'Config'