Mmdetection: No module named 'mmcv.cnn.weight_init'

Created on 24 Jul 2020  路  6Comments  路  Source: open-mmlab/mmdetection

Please tell me the solution, thanks

/home/sarim/PycharmProjects/trajectory_prediction/venv/lib/python3.7/site-packages/setuptools/distutils_patch.py:26: UserWarning: Distutils was imported before Setuptools. This usage is discouraged and may exhibit undesirable behaviors or errors. Please use Setuptools' objects directly or at least import Setuptools first.
  "Distutils was imported before Setuptools. This usage is discouraged "
Traceback (most recent call last):
  File "/home/sarim/PycharmProjects/trajectory_prediction/obj_det_track.py", line 13, in <module>
    from DetectoRS.mmdet.apis import init_detector, inference_detector
  File "/home/sarim/PycharmProjects/trajectory_prediction/DetectoRS/mmdet/apis/__init__.py", line 1, in <module>
    from .inference import (async_inference_detector, inference_detector,
  File "/home/sarim/PycharmProjects/trajectory_prediction/DetectoRS/mmdet/apis/inference.py", line 13, in <module>
    from mmdet.models import build_detector
  File "/home/sarim/PycharmProjects/trajectory_prediction/DetectoRS/mmdet/models/__init__.py", line 3, in <module>
    from .bbox_heads import *  # noqa: F401,F403
  File "/home/sarim/PycharmProjects/trajectory_prediction/DetectoRS/mmdet/models/bbox_heads/__init__.py", line 3, in <module>
    from .double_bbox_head import DoubleConvFCBBoxHead
  File "/home/sarim/PycharmProjects/trajectory_prediction/DetectoRS/mmdet/models/bbox_heads/double_bbox_head.py", line 2, in <module>
    from mmcv.cnn.weight_init import normal_init, xavier_init
ModuleNotFoundError: No module named 'mmcv.cnn.weight_init'

Process finished with exit code 1

Most helpful comment

all you need to do is
pip install mmcv==0.4.3

All 6 comments

Try this: pip install mmcv-full==latest+torch1.5.0+cu101 -f https://openmmlab.oss-accelerate.aliyuncs.com/mmcv/dist/index.html

The version you used may be too old.

pip install mmcv-full==latest+torch1.5.0+cu101 -f https://openmmlab.oss-accelerate.aliyuncs.com/mmcv/dist/index.html

still getting same issue as mentioned

I have the same problem too.
When I run the command from mmdet.models import build_detector I got the error below:

File "/usr/src/app/mmdetection/mmdet/models/__init__.py", line 3, in <module>
    from .bbox_heads import *  # noqa: F401,F403
  File "/usr/src/app/mmdetection/mmdet/models/bbox_heads/__init__.py", line 3, in <module>
    from .double_bbox_head import DoubleConvFCBBoxHead
  File "/usr/src/app/mmdetection/mmdet/models/bbox_heads/double_bbox_head.py", line 2, in <module>
    from mmcv.cnn.weight_init import normal_init, xavier_init
ModuleNotFoundError: No module named 'mmcv.cnn.weight_init'

This is what I have from the command python mmdetection/mmdet/utils/collect_env.py:

sys.platform: linux
Python: 3.6.9 |Anaconda, Inc.| (default, Jul 30 2019, 19:07:31) [GCC 7.3.0]
CUDA available: True
CUDA_HOME: /usr/local/cuda
NVCC: Cuda compilation tools, release 10.1, V10.1.243
GPU 0: GeForce RTX 2070 SUPER
GCC: gcc (Ubuntu 5.4.0-6ubuntu1~16.04.11) 5.4.0 20160609
PyTorch: 1.3.0
PyTorch compiling details: PyTorch built with:
  - GCC 7.3
  - Intel(R) Math Kernel Library Version 2019.0.4 Product Build 20190411 for Intel(R) 64 architecture applications
  - Intel(R) MKL-DNN v0.20.5 (Git Hash 0125f28c61c1f822fd48570b4c1066f96fcb9b2e)
  - OpenMP 201511 (a.k.a. OpenMP 4.5)
  - NNPACK is enabled
  - CUDA Runtime 10.1
  - NVCC architecture flags: -gencode;arch=compute_35,code=sm_35;-gencode;arch=compute_50,code=sm_50;-gencode;arch=compute_60,code=sm_60;-gencode;arch=compute_61,code=sm_61;-gencode;arch=compute_70,code=sm_70;-gencode;arch=compute_75,code=sm_75;-gencode;arch=compute_50,code=compute_50
  - CuDNN 7.6.3
  - Magma 2.5.1
  - Build settings: BLAS=MKL, BUILD_NAMEDTENSOR=OFF, BUILD_TYPE=Release, CXX_FLAGS= -Wno-deprecated -fvisibility-inlines-hidden -fopenmp -DUSE_FBGEMM -DUSE_QNNPACK -DUSE_PYTORCH_QNNPACK -O2 -fPIC -Wno-narrowing -Wall -Wextra -Wno-missing-field-initializers -Wno-type-limits -Wno-array-bounds -Wno-unknown-pragmas -Wno-sign-compare -Wno-unused-parameter -Wno-unused-variable -Wno-unused-function -Wno-unused-result -Wno-strict-overflow -Wno-strict-aliasing -Wno-error=deprecated-declarations -Wno-stringop-overflow -Wno-error=pedantic -Wno-error=redundant-decls -Wno-error=old-style-cast -fdiagnostics-color=always -faligned-new -Wno-unused-but-set-variable -Wno-maybe-uninitialized -fno-math-errno -fno-trapping-math -Wno-stringop-overflow, DISABLE_NUMA=1, PERF_WITH_AVX=1, PERF_WITH_AVX2=1, PERF_WITH_AVX512=1, USE_CUDA=True, USE_EXCEPTION_PTR=1, USE_GFLAGS=OFF, USE_GLOG=OFF, USE_MKL=ON, USE_MKLDNN=ON, USE_MPI=OFF, USE_NCCL=ON, USE_NNPACK=ON, USE_OPENMP=ON, USE_STATIC_DISPATCH=OFF,

TorchVision: 0.4.1a0+d94043a
OpenCV: 4.2.0
MMCV: 1.0.5
MMDetection: 1.2.0+unknown
MMDetection Compiler: GCC 5.4
MMDetection CUDA Compiler: 10.1

The project is in a docker container with the image

FROM pytorch/pytorch:1.3-cuda10.1-cudnn7-devel

How did you solve it? Please help.

all you need to do is
pip install mmcv==0.4.3

all you need to do is
pip install mmcv==0.4.3

god like!

Was this page helpful?
0 / 5 - 0 ratings