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

No module named 'mmcv.cnn.weight_init' #3402

Closed
sarimmehdi opened this issue Jul 24, 2020 · 12 comments
Closed

No module named 'mmcv.cnn.weight_init' #3402

sarimmehdi opened this issue Jul 24, 2020 · 12 comments

Comments

@sarimmehdi
Copy link

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
@azibit
Copy link
Contributor

azibit commented Jul 25, 2020

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

@hellock
Copy link
Member

hellock commented Jul 26, 2020

The version you used may be too old.

@hellock hellock closed this as completed Jul 26, 2020
@dhananjayd232
Copy link

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

@danielefundaro
Copy link

danielefundaro commented Aug 6, 2020

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.

@kaizhan
Copy link

kaizhan commented Aug 26, 2020

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

@Armstrong-lsw
Copy link

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

god like!

@PrithwishChakraborty
Copy link

even after installing mmcv==0.4.3 getting the same error

@dav-ell
Copy link

dav-ell commented Apr 11, 2023

Same. mmcv is on 2.0.0 now, also.

@KaneiGi
Copy link

KaneiGi commented Apr 14, 2023

change the code
from mmcv.cnn.weight_init
to mmcv.cnn

@wuchengyu123
Copy link

Actually pip install mmcv==1.0.2 will fix this. I tried for accidently and succeed.

@WH0226
Copy link

WH0226 commented May 10, 2024

from mmengine.model import constant_init

@maxiuw
Copy link

maxiuw commented Jul 25, 2024

if you're using xavier_init it's in from mmengine.model import xavier_init instead :)

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