MMCV (2.1.0) error: ModuleNotFoundError: No module named 'mmcv._ext'

965 views Asked by At

Running Python 3.10 in a Conda env.

have tried installing mmcv via pip install mmcv and mim install mmcv, both create the same error.

Followed instructions here: https://mmcv.readthedocs.io/en/latest/faq.html?highlight=mmcv._ext but mmcv-full only works up to mmcv 1.7, I need >2.0.0

Full error:

  File "/Users/andrewmccalister/Documents/segmentTool/FoodSeg103/demo/deployments/image_demo_deployment/updated_source_mb.py", line 14, in <module>
    from mmseg.apis import inference_model, init_model, show_result_pyplot
  File "/Users/andrewmccalister/miniconda3/envs/py_3.10/lib/python3.10/site-packages/mmseg/apis/__init__.py", line 2, in <module>
    from .inference import inference_model, init_model, show_result_pyplot
  File "/Users/andrewmccalister/miniconda3/envs/py_3.10/lib/python3.10/site-packages/mmseg/apis/inference.py", line 14, in <module>
    from mmseg.models import BaseSegmentor
  File "/Users/andrewmccalister/miniconda3/envs/py_3.10/lib/python3.10/site-packages/mmseg/models/__init__.py", line 3, in <module>
    from .backbones import *  # noqa: F401,F403
  File "/Users/andrewmccalister/miniconda3/envs/py_3.10/lib/python3.10/site-packages/mmseg/models/backbones/__init__.py", line 2, in <module>
    from .beit import BEiT
  File "/Users/andrewmccalister/miniconda3/envs/py_3.10/lib/python3.10/site-packages/mmseg/models/backbones/beit.py", line 19, in <module>
    from ..utils import PatchEmbed
  File "/Users/andrewmccalister/miniconda3/envs/py_3.10/lib/python3.10/site-packages/mmseg/models/utils/__init__.py", line 2, in <module>
    from .basic_block import BasicBlock, Bottleneck
  File "/Users/andrewmccalister/miniconda3/envs/py_3.10/lib/python3.10/site-packages/mmseg/models/utils/basic_block.py", line 10, in <module>
    from mmseg.utils import OptConfigType
  File "/Users/andrewmccalister/miniconda3/envs/py_3.10/lib/python3.10/site-packages/mmseg/utils/__init__.py", line 24, in <module>
    from .mask_classification import MatchMasks, seg_data_to_instance_data
  File "/Users/andrewmccalister/miniconda3/envs/py_3.10/lib/python3.10/site-packages/mmseg/utils/mask_classification.py", line 5, in <module>
    from mmcv.ops import point_sample
  File "/Users/andrewmccalister/miniconda3/envs/py_3.10/lib/python3.10/site-packages/mmcv/ops/__init__.py", line 3, in <module>
    from .active_rotated_filter import active_rotated_filter
  File "/Users/andrewmccalister/miniconda3/envs/py_3.10/lib/python3.10/site-packages/mmcv/ops/active_rotated_filter.py", line 10, in <module>
    ext_module = ext_loader.load_ext(
  File "/Users/andrewmccalister/miniconda3/envs/py_3.10/lib/python3.10/site-packages/mmcv/utils/ext_loader.py", line 13, in load_ext
    ext = importlib.import_module('mmcv.' + name)
  File "/Users/andrewmccalister/miniconda3/envs/py_3.10/lib/python3.10/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
ModuleNotFoundError: No module named 'mmcv._ext'```
1

There are 1 answers

0
Lukas Brunner On

It may be a bit late, but I had the same issue.

For some reason, the recommended ways gave me problems, but it always worked for me when I figured out my PyTorch and CUDA version that I wanted and directly installed the matching wheel using pip. E.g. with CUDA version 11.7 and PyTorch 2 the command would be:

pip install mmcv==2.0.1 -f https://download.openmmlab.com/mmcv/dist/cu117/torch2.0/index.html.

You have to try to find whether a build for your desired versions exists.