Someone has already post this issue earlier, and I just wanna say I got the same issue.
I'm using mmedetection on colab. I installed the program as usual, but when I tried to import inference_detector from mmdet.apis, I got the error as described in the title which I've never met before. I thought it may because some updates on your side were on progress, but I wasn't sure. Any suggestion? Thank you.
And also, I received the link to the page of installing mmdet on colab from one of you earlier in another issue I posted. This is the address as I opened the page on colab (https://github.com/openmmlab/mmdetection/blob/master/demo/mmdet_inference_colab.ipynb)
However, when I rechecked the page after the error occurred, it was gone.
same problem.
Hi @ahchang2
You may try to install mmcv==0.6.2.
Hi @ahchang2
You may try to install mmcv==0.6.2.
But I received another error after install mmcv==0.6.2
Traceback (most recent call last):
File "tools/train.py", line 13, in
from mmdet.apis import set_random_seed, train_detector
File "/home/ubuntu/mmdetection/mmdet/apis/__init__.py", line 1, in
from .inference import (async_inference_detector, inference_detector,
File "/home/ubuntu/mmdetection/mmdet/apis/inference.py", line 6, in
from mmcv.ops import RoIAlign, RoIPool
ModuleNotFoundError: No module named 'mmcv.ops'
@ShidiDaisy
There basically are two workarounds.
pip install mmcv-full or install pre-build ones from here. @ShidiDaisy
There basically are two workarounds.
- Install latest mmdet and
pip install mmcv-fullor install pre-build ones from here.- Install mmcv==0.6.2 and mmdet==2.2.1
But I still hit this error after I pip install mmcv-full.
Traceback (most recent call last):
File "tools/train.py", line 153, in
main()
File "tools/train.py", line 126, in main
cfg.model, train_cfg=cfg.train_cfg, test_cfg=cfg.test_cfg)
File "/home/ubuntu/mmdetection/mmdet/models/builder.py", line 65, in build_detector
return build(cfg, DETECTORS, dict(train_cfg=train_cfg, test_cfg=test_cfg))
File "/home/ubuntu/mmdetection/mmdet/models/builder.py", line 30, in build
return build_from_cfg(cfg, registry, default_args)
File "/home/ubuntu/anaconda3/envs/open-mmlab/lib/python3.7/site-packages/mmcv/utils/registry.py", line 167, in build_from_cfg
return obj_cls(**args)
TypeError: __init__() got an unexpected keyword argument 'bbox_roi_extractor'
I also tried 'python setup.py develop',but still can't get rid of the error.
@ShidiDaisy
There basically are two workarounds.
- Install latest mmdet and
pip install mmcv-fullor install pre-build ones from here.- Install mmcv==0.6.2 and mmdet==2.2.1
I was getting ModuleNotFoundError: No module named 'mmcv.ops', so I tried installing mmcv==0.6.2 and mmdet==2.2.1, but then I got the error, ERROR: No matching distribution found for mmdet==2.2.1. The training was working when I installed mmcv-full however I was having the same issue as #3259, so I'm currently following the Author of the issue #3259, solution. Any help would be appreciated.
Same error. Oh my god.
This works 100%.
export TORCH_CUDA_ARCH_LIST="6.0 6.1 7.0+PTX"
export TORCH_NVCC_FLAGS="-Xfatbin -compress-all"
export CMAKE_PREFIX_PATH="$(dirname $(which conda))/../"
pip uninstall -y mmdet mmcv
conda install -y cython==0.28.5
#pip install mmcv==0.2.15
pip install mmcv==0.6.2 terminaltables Pillow==6.2.2
export FORCE_CUDA="1"
pip install "git+https://github.com/open-mmlab/cocoapi.git#subdirectory=pycocotools"
pip install "git+https://github.com/cocodataset/cocoapi.git#subdirectory=PythonAPI"
#git clone https://github.com/open-mmlab/mmdetection.git mmdetection
#cd mmdetection
rm -rf build
pip install -r requirements/build.txt
python setup.py develop
pip install --no-cache-dir -e .
pip install mmcv==0.6.2 mmcv-full
This works 100%.
export TORCH_CUDA_ARCH_LIST="6.0 6.1 7.0+PTX" export TORCH_NVCC_FLAGS="-Xfatbin -compress-all" export CMAKE_PREFIX_PATH="$(dirname $(which conda))/../" pip uninstall -y mmdet mmcv conda install -y cython==0.28.5 #pip install mmcv==0.2.15 pip install mmcv==0.6.2 terminaltables Pillow==6.2.2 export FORCE_CUDA="1" pip install "git+https://github.com/open-mmlab/cocoapi.git#subdirectory=pycocotools" pip install "git+https://github.com/cocodataset/cocoapi.git#subdirectory=PythonAPI" #git clone https://github.com/open-mmlab/mmdetection.git mmdetection #cd mmdetection rm -rf build pip install -r requirements/build.txt python setup.py develop pip install --no-cache-dir -e . pip install mmcv==0.6.2 mmcv-full
But I still got this issue after following your solution. Have you seen this issue?
Traceback (most recent call last):
File "demo/image_demo.py", line 3, in
from mmdet.apis import inference_detector, init_detector, show_result_pyplot
File "/home/ubuntu/mmdetection/mmdet/apis/__init__.py", line 1, in
from .inference import (async_inference_detector, inference_detector,
File "/home/ubuntu/mmdetection/mmdet/apis/inference.py", line 6, in
from mmcv.ops import RoIAlign, RoIPool
File "/home/ubuntu/anaconda3/envs/open-mmlab/lib/python3.7/site-packages/mmcv/ops/__init__.py", line 1, in
from .bbox import bbox_overlaps
File "/home/ubuntu/anaconda3/envs/open-mmlab/lib/python3.7/site-packages/mmcv/ops/bbox.py", line 3, in
ext_module = ext_loader.load_ext('_ext', ['bbox_overlaps'])
File "/home/ubuntu/anaconda3/envs/open-mmlab/lib/python3.7/site-packages/mmcv/utils/ext_loader.py", line 12, in load_ext
assert hasattr(ext, fun), f'{fun} miss in module {name}'
AssertionError: bbox_overlaps miss in module _ext
Hi @ShidiDaisy
Please first uninstall any previous version of mmcv.
And run pip install mmcv-full.
Please refer to install guide for details.
@xvjiarui Following latest install guide and cloned lastest master branch code. I receive the error:
ModuleNotFoundError: No module named 'mmcv._ext'
Hi @peeyushpashine
You need to install mmcv-full.
You may run pip install mmcv-full.
@xvjiarui Yes, still the same issue.
Hi @ShidiDaisy
Please first uninstall any previous version of mmcv.
And runpip install mmcv-full.
Please refer to install guide for details.
But I got this issue:
import mmcv
ModuleNotFoundError: No module named 'mmcv'
after I
pip uninstall mmcv,
pip install mmcv-full
Hi @peeyushpashine , @ShidiDaisy ,
You may need to use pip uninstall mmcv multiple times to ensure that there is no old mmcv in the python site-packages first. Some times the mmcv might not be totally wiped out for some reasons.
Then you can install mmcv-full using pip install mmcv-full. Please ensure that this time mmcv is successfully compiled and installed.
I did a fresh build with a new environment, and everything works as expected.
Hi @peeyushpashine
You need to install mmcv-full.
You may runpip install mmcv-full.
useless
Perhaps it's a path related issue? The following command worked:
python -m pip install mmcv==0.6.2
Somehow in the latest master code i do not see issue anymore.
Here is the complete solution by setting all requirements:
from IPython.display import clear_output
os.environ['PYTHONPATH'] = "/usr/bin/python3"
!wget https://repo.continuum.io/miniconda/Miniconda3-4.5.4-Linux-x86_64.sh && bash Miniconda3-4.5.4-Linux-x86_64.sh -bfp /usr/local
!conda create -n open-mmlab python=3.7 -y
!conda activate open-mmlab
!conda install --yes pytorch torchvision -c pytorch
!conda install --yes pytorch cudatoolkit=10.1 torchvision -c pytorch
!pip install mmcv-full
!git clone <YOUR GIT REPO>
!pip install mmcv
!pip install -r /content/mmdetection/requirements/build.txt
!pip install -v -e . # or "python setup.py develop"
!pip install -r /content/mmdetection/requirements/optional.txt
%cd mmdetection
!python setup.py develop
!conda install --yes ipykernel
clear_output(wait=True)
print('Done!')
Here is the complete solution by setting all requirements:
from IPython.display import clear_output
os.environ['PYTHONPATH'] = "/usr/bin/python3"
!wget https://repo.continuum.io/miniconda/Miniconda3-4.5.4-Linux-x86_64.sh && bash Miniconda3-4.5.4-Linux-x86_64.sh -bfp /usr/local
!conda create -n open-mmlab python=3.7 -y
!conda activate open-mmlab
!conda install --yes pytorch torchvision -c pytorch
!conda install --yes pytorch cudatoolkit=10.1 torchvision -c pytorch
!pip install mmcv-full
!git clone <YOUR GIT REPO>
!pip install mmcv
!pip install -r /content/mmdetection/requirements/build.txt
!pip install -v -e . # or "python setup.py develop"
!pip install -r /content/mmdetection/requirements/optional.txt
%cd mmdetection
!python setup.py develop
!conda install --yes ipykernel
clear_output(wait=True)
print('Done!')
If you installed mmcv-full, you should not install mmcv. You can try to not install mmcv and see if it works.
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
pip uninstall mmcv
pip install mmcv-full
I fixed by
pip install mmcv-full==1.0.5
It may depend on version?
first: pip uninstall mmcv
then: pip install mmcv-full==latest+torch1.5.0+cu101 -f https://download.openmmlab.com/mmcv/dist/index.html
my mmdet version is 2.4.0, mmcv>=1.1.0
If you have installed the correct version of cfg,remember use 'conda active mmdet'. It works
Most helpful comment
first: pip uninstall mmcv
then: pip install mmcv-full==latest+torch1.5.0+cu101 -f https://download.openmmlab.com/mmcv/dist/index.html
my mmdet version is 2.4.0, mmcv>=1.1.0