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

ModuleNotFoundError: No module named 'mmcv._ext' #204

Closed
Liyw979 opened this issue Mar 2, 2020 · 26 comments
Closed

ModuleNotFoundError: No module named 'mmcv._ext' #204

Liyw979 opened this issue Mar 2, 2020 · 26 comments

Comments

@Liyw979
Copy link

Liyw979 commented Mar 2, 2020

I clone the repo and run pip install.

When I run test_image.py, this error shows up.

from mmcv._ext import flow_warp_c

@xjock
Copy link

xjock commented Mar 20, 2020

Just cd ..

@hellock hellock closed this as completed May 3, 2020
@DuinoDu
Copy link

DuinoDu commented Jul 12, 2020

Any update?

@DuinoDu
Copy link

DuinoDu commented Jul 12, 2020

Build mmcv with MMCV_WITH_OPS=1 may help.

@lui-shex
Copy link

what you mean MMCV_WITH_OPS=1? I can't run MMCV_WITH_OPS=1 pip install -e .

@NikZak
Copy link

NikZak commented Jul 20, 2020

Workaround:
pip uninstall mmcv mmcv-full
git clone https://github.com/open-mmlab/mmcv.git
cd mmcv
MMCV_WITH_OPS=1 pip install -e .

@sailfish009
Copy link

Workaround:
pip uninstall mmcv mmcv-full
git clone https://github.com/open-mmlab/mmcv.git
cd mmcv
MMCV_WITH_OPS=1 pip install -e .

Thanks! works for me.

@guofuxin
Copy link

what you mean MMCV_WITH_OPS=1? I can't run MMCV_WITH_OPS=1 pip install -e .

I also can't run it.Are you deal with it?

@guofuxin
Copy link

MMCV_WITH_OPS=1 pip install -e

I can't run MMCV_WITH_OPS=1 pip install -e,
the terminal is " -e option requires 1 argument",
can you help me ? thank you very much

@NikZak
Copy link

NikZak commented Jul 28, 2020

You should not forget the dot in the end ".". Which just means installing from current directory.
It is not
MMCV_WITH_OPS=1 pip install -e
It is
MMCV_WITH_OPS=1 pip install -e .

@liuligang123
Copy link

I run the MMCV_WITH_OPS=1 pip install -e . and then solve the problem
just wait when running setup.py develop for mmcv-full

@Never-up
Copy link

I run the MMCV_WITH_OPS=1 pip install -e . and then solve the problem
just wait when running setup.py develop for mmcv-full

请问你解决了吗,我也遇到了

@VoldemortGin
Copy link

I run the MMCV_WITH_OPS=1 pip install -e . and then solve the problem

That didn't work for me. And my mmcv version is 1.1.3. Still, I got ModuleNotFoundError: No module named 'mmcv._ext' Error when I tried to run a demo.

Any solution? My log is as below:

python demo/image_demo.py demo/demo.jpg configs/mask_rcnn/mask_rcnn_x101_64x4d_fpn_1x_coco.py 

checkpoints/mask_rcnn_x101_64x4d_fpn_1x_coco_20200201-9352eb0d.pth 
Traceback (most recent call last):
  File "demo/image_demo.py", line 3, in <module>
    from mmdet.apis import inference_detector, init_detector, show_result_pyplot
  File "/home/linhan/workspace/mmcv/mmdetection/mmdet/apis/__init__.py", line 1, in <module>
    from .inference import (async_inference_detector, inference_detector,
  File "/home/linhan/workspace/mmcv/mmdetection/mmdet/apis/inference.py", line 7, in <module>
    from mmcv.ops import RoIAlign, RoIPool
  File "/home/linhan/anaconda3/lib/python3.7/site-packages/mmcv-1.1.3-py3.7-linux-x86_64.egg/mmcv/ops/__init__.py", line 1, in <module>
    from .bbox import bbox_overlaps
  File "/home/linhan/anaconda3/lib/python3.7/site-packages/mmcv-1.1.3-py3.7-linux-x86_64.egg/mmcv/ops/bbox.py", line 3, in <module>
    ext_module = ext_loader.load_ext('_ext', ['bbox_overlaps'])
  File "/home/linhan/anaconda3/lib/python3.7/site-packages/mmcv-1.1.3-py3.7-linux-x86_64.egg/mmcv/utils/ext_loader.py", line 11, in load_ext
    ext = importlib.import_module('mmcv.' + name)
  File "/home/linhan/anaconda3/lib/python3.7/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
ModuleNotFoundError: No module named 'mmcv._ext'

Thank you in advance.

@neomukul
Copy link

@VoldemortGin are you able to resolve this issue, I am also having the same issue.
if i Install mmcv-full it is not working as mmcv-1.2 version is not compatible with mmdet and if i install mmcv-1.1.3 it throws error "ModuleNotFoundError: No module named 'mmcv._ext'"?

@surendrallam
Copy link

Workaround:
pip uninstall mmcv mmcv-full
git clone https://github.com/open-mmlab/mmcv.git
cd mmcv
MMCV_WITH_OPS=1 pip install -e .

This worked for me... Thanks a ton @NikZak

@korhun
Copy link

korhun commented Feb 3, 2021

For windows, this worked for me:

pip uninstall mmcv
pip uninstall mmcv-full
git clone https://github.com/open-mmlab/mmcv.git
cd mmcv
set MMCV_WITH_OPS=1
pip install -e .

@surendrallam
Copy link

surendrallam commented Feb 3, 2021 via email

@SamMohel
Copy link

I run the MMCV_WITH_OPS=1 pip install -e . and then solve the problem

That didn't work for me. And my mmcv version is 1.1.3. Still, I got ModuleNotFoundError: No module named 'mmcv._ext' Error when I tried to run a demo.

Any solution? My log is as below:

python demo/image_demo.py demo/demo.jpg configs/mask_rcnn/mask_rcnn_x101_64x4d_fpn_1x_coco.py 

checkpoints/mask_rcnn_x101_64x4d_fpn_1x_coco_20200201-9352eb0d.pth 
Traceback (most recent call last):
  File "demo/image_demo.py", line 3, in <module>
    from mmdet.apis import inference_detector, init_detector, show_result_pyplot
  File "/home/linhan/workspace/mmcv/mmdetection/mmdet/apis/__init__.py", line 1, in <module>
    from .inference import (async_inference_detector, inference_detector,
  File "/home/linhan/workspace/mmcv/mmdetection/mmdet/apis/inference.py", line 7, in <module>
    from mmcv.ops import RoIAlign, RoIPool
  File "/home/linhan/anaconda3/lib/python3.7/site-packages/mmcv-1.1.3-py3.7-linux-x86_64.egg/mmcv/ops/__init__.py", line 1, in <module>
    from .bbox import bbox_overlaps
  File "/home/linhan/anaconda3/lib/python3.7/site-packages/mmcv-1.1.3-py3.7-linux-x86_64.egg/mmcv/ops/bbox.py", line 3, in <module>
    ext_module = ext_loader.load_ext('_ext', ['bbox_overlaps'])
  File "/home/linhan/anaconda3/lib/python3.7/site-packages/mmcv-1.1.3-py3.7-linux-x86_64.egg/mmcv/utils/ext_loader.py", line 11, in load_ext
    ext = importlib.import_module('mmcv.' + name)
  File "/home/linhan/anaconda3/lib/python3.7/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
ModuleNotFoundError: No module named 'mmcv._ext'

Thank you in advance.

did you solve it ?

@TheFebrin
Copy link

For people still struggling with this error: ModuleNotFoundError: No module named 'mmcv._ext'

  1. It's important that pytorch - cuda - mmcv are compatible
  2. Therefore first you should check your cuda version nvidia-smi
+-----------------------------------------------------------------------------+
| NVIDIA-SMI 450.102.04   Driver Version: 450.102.04   CUDA Version: 11.0     |
|-------------------------------+----------------------+----------------------+

For example mine is 11.0

  1. Then download correct pytorch:
pip install torch==1.8.0+cu111 torchvision==0.9.0+cu111 torchaudio==0.8.0 -f https://download.pytorch.org/whl/torch_stable.html

This is Pytorch 1.8.0 with cuda 11.1.

  1. Install correct mmcv as they mention in their README
pip install mmcv-full -f https://download.openmmlab.com/mmcv/dist/cu111/torch1.8.0/index.html

/cu111/torch1.8.0/ see how cuda and torch versions are matching

  1. It should work 😃
Python 3.7.5 (default, Feb 23 2021, 13:22:40) 
[GCC 8.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from mmcv.ops import get_compiling_cuda_version, get_compiler_version
>>> print(get_compiling_cuda_version())
11.1
>>> print(get_compiler_version())
GCC 7.3
>>> 

PS Here's our project where we used mmdet

@THEBEST-cloud
Copy link

what you mean MMCV_WITH_OPS=1? I can't run MMCV_WITH_OPS=1 pip install -e .

I also can't run it.Are you deal wi

I run the MMCV_WITH_OPS=1 pip install -e . and then solve the problem
just wait when running setup.py develop for mmcv-full

请问你解决了吗,我也遇到了

请问怎么解决的啊 MMCV_WITH_OPS=1 pip install -e .这个命令执行报错 'MMCV_WITH_OPS' 不是内部或外部命令,也不是可运行的程序

@xhjiang1998
Copy link

For windows, this worked for me:

pip uninstall mmcv
pip uninstall mmcv-full
git clone https://github.com/open-mmlab/mmcv.git
cd mmcv
set MMCV_WITH_OPS=1
pip install -e .

this is the accuracy

@jankrans
Copy link

For windows, this worked for me:
pip uninstall mmcv
pip uninstall mmcv-full
git clone https://github.com/open-mmlab/mmcv.git
cd mmcv
set MMCV_WITH_OPS=1
pip install -e .

Still getting the error mentioned in the title when trying this on windows conda environment.
cudatoolkit=11.3.1
mmcv=1.4.5
mmdet=2.21.0
python=3.7.11
torchvision=0.11.3

Would also rather have the mmdet-full. Been struggling for a long time with all these versions. Someone with a working windows version that could provide quick explanation?

@Lucifer60
Copy link

I am really appreciate that after stuggling one day on "No module named 'mmcv._ext'" problem that after uninstall mmcv-full and uninstall mmcv .I can't pip install -e. So I use your method "pip install mmcv-full -f https://download.openmmlab.com/mmcv/dist/cu111/torch1.8.0/index.html" And it work well now.

@EgShes
Copy link

EgShes commented Mar 27, 2024

For me helped

  1. Install right version of torch for your cuda. Get command from here
    pip install torch==2.0.0 torchvision==0.15.1 torchaudio==2.0.1 --index-url https://download.pytorch.org/whl/cu118
  2. Install right mmcv for your torch. Get command from here
    pip install mmcv==2.0.1 -f https://download.openmmlab.com/mmcv/dist/cu118/torch2.0/index.html

@rhelck
Copy link

rhelck commented Jun 11, 2024

Have the same issue, the approaches listed here do not work for me

This is the only thing preventing me from using your model, could you guys either simplify the installation process or provide more reliable instructions for installing the model?

I don't mean to come across as impatient, but I was excited to use your model after seeing your object detection benchmark results, and this issue looks like its been around for a while

@hutIngk
Copy link

hutIngk commented Jun 26, 2024

Workaround: pip uninstall mmcv mmcv-full git clone https://github.com/open-mmlab/mmcv.git cd mmcv MMCV_WITH_OPS=1 pip install -e .

sry, i have tried your method, but it is seems to work failed in Windows,it reports MMCV_WITH_OPS is not a inner or out command, so are u guys who said to slove this problem all work on linux or other else ?

@Moyago
Copy link

Moyago commented Oct 28, 2024

For me helped

1. Install right version of torch for your cuda. Get command from [here](https://pytorch.org/get-started/previous-versions/)
   `pip install torch==2.0.0 torchvision==0.15.1 torchaudio==2.0.1 --index-url https://download.pytorch.org/whl/cu118`

2. Install right mmcv for your torch. Get command from [here](https://mmcv.readthedocs.io/en/latest/get_started/installation.html#install-with-pip)
   `pip install mmcv==2.0.1 -f https://download.openmmlab.com/mmcv/dist/cu118/torch2.0/index.html`

this reply definitely solved my problem, thanks sir! @EgShes

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