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 'mmdet' #6849

Closed
lenardxu opened this issue Dec 21, 2021 · 5 comments
Closed

ModuleNotFoundError: No module named 'mmdet' #6849

lenardxu opened this issue Dec 21, 2021 · 5 comments

Comments

@lenardxu
Copy link

Thanks for your error report and we appreciate it a lot.

Checklist

  1. I have searched related issues but cannot get the expected help.
  2. I have read the FAQ documentation but cannot get the expected help.

Describe the bug
I am going to use the repo "https://github.com/VDIGPKU/CBNetV2", which is built based on mmdetection 2.14.0. When I installed all relevant python packages (with their dependencies) according to the mmdetection instructions, and try importing mmdet, the ModuleNotFoundError: No module named 'mmdet' takes place. As a debugging try, I've checked if the mmdet(==2.14.0) is already installed in the environment, which is actually done by using pip show or pip list.

Reproduction

  1. What command or script did you run?
  1. Did you make any modifications on the code or config? Did you understand what you have modified?
    No.
  2. What dataset did you use?

Environment

  1. Please run python mmdet/utils/collect_env.py to collect necessary environment information and paste it here.
Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
sys.platform: linux
Python: 3.7.12 | packaged by conda-forge | (default, Oct 26 2021, 06:08:53) [GCC 9.4.0]
CUDA available: True
GPU 0: Tesla P100-PCIE-16GB
CUDA_HOME: /usr/local/cuda
NVCC: Build cuda_11.0_bu.TC445_37.28845127_0
GCC: gcc (Ubuntu 9.3.0-17ubuntu1~20.04) 9.3.0
PyTorch: 1.7.0+cu110
PyTorch compiling details: PyTorch built with:
  - GCC 7.3
  - C++ Version: 201402
  - Intel(R) Math Kernel Library Version 2020.0.0 Product Build 20191122 for Intel(R) 64 architecture applications
  - Intel(R) MKL-DNN v1.6.0 (Git Hash 5ef631a030a6f73131c77892041042805a06064f)
  - OpenMP 201511 (a.k.a. OpenMP 4.5)
  - NNPACK is enabled
  - CPU capability usage: AVX2
  - CUDA Runtime 11.0
  - NVCC architecture flags: -gencode;arch=compute_37,code=sm_37;-gencode;arch=compute_50,code=sm_50;-gencode;arch=compute_60,code=sm_60;-gencode;arch=compute_70,code=sm_70;-gencode;arch=compute_75,code=sm_75;-gencode;arch=compute_80,code=sm_80
  - CuDNN 8.0.4
  - Magma 2.5.2
  - Build settings: BLAS=MKL, BUILD_TYPE=Release, CXX_FLAGS= -Wno-deprecated -fvisibility-inlines-hidden -DUSE_PTHREADPOOL -fopenmp -DNDEBUG -DUSE_FBGEMM -DUSE_QNNPACK -DUSE_PYTORCH_QNNPACK -DUSE_XNNPACK -DUSE_VULKAN_WRAPPER -O2 -fPIC -Wno-narrowing -Wall -Wextra -Werror=return-type -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-unused-local-typedefs -Wno-strict-overflow -Wno-strict-aliasing -Wno-error=deprecated-declarations -Wno-stringop-overflow -Wno-psabi -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 -Werror=format -Wno-stringop-overflow, PERF_WITH_AVX=1, PERF_WITH_AVX2=1, PERF_WITH_AVX512=1, USE_CUDA=ON, 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, 

TorchVision: 0.8.0
OpenCV: 4.5.4
MMCV: 1.4.0
MMCV Compiler: GCC 7.3
MMCV CUDA Compiler: 11.0
MMDetection: 2.14.0+
  1. You may add addition that may be helpful for locating the problem, such as
    • How you installed PyTorch [e.g., pip, conda, source] Answer:pip
    • Other environment variables that may be related (such as $PATH, $LD_LIBRARY_PATH, $PYTHONPATH, etc.)

Error traceback
This is the log for installing mmdet==2.14.0

/kaggle/working/cbnetv2
Obtaining file:///kaggle/working/cbnetv2
  Preparing metadata (setup.py) ... done
Requirement already satisfied: matplotlib in /opt/conda/lib/python3.7/site-packages (from mmdet==2.14.0) (3.5.0)
Requirement already satisfied: numpy in /opt/conda/lib/python3.7/site-packages (from mmdet==2.14.0) (1.19.5)
Requirement already satisfied: six in /opt/conda/lib/python3.7/site-packages (from mmdet==2.14.0) (1.16.0)
Requirement already satisfied: terminaltables in /opt/conda/lib/python3.7/site-packages (from mmdet==2.14.0) (3.1.0)
Requirement already satisfied: timm in /opt/conda/lib/python3.7/site-packages (from mmdet==2.14.0) (0.4.12)
Requirement already satisfied: pycocotools in /opt/conda/lib/python3.7/site-packages (from mmdet==2.14.0) (2.0.3)
Requirement already satisfied: cycler>=0.10 in /opt/conda/lib/python3.7/site-packages (from matplotlib->mmdet==2.14.0) (0.11.0)
Requirement already satisfied: python-dateutil>=2.7 in /opt/conda/lib/python3.7/site-packages (from matplotlib->mmdet==2.14.0) (2.8.0)
Requirement already satisfied: setuptools-scm>=4 in /opt/conda/lib/python3.7/site-packages (from matplotlib->mmdet==2.14.0) (6.3.2)
Requirement already satisfied: packaging>=20.0 in /opt/conda/lib/python3.7/site-packages (from matplotlib->mmdet==2.14.0) (21.0)
Requirement already satisfied: pillow>=6.2.0 in /opt/conda/lib/python3.7/site-packages (from matplotlib->mmdet==2.14.0) (8.2.0)
Requirement already satisfied: fonttools>=4.22.0 in /opt/conda/lib/python3.7/site-packages (from matplotlib->mmdet==2.14.0) (4.28.2)
Requirement already satisfied: kiwisolver>=1.0.1 in /opt/conda/lib/python3.7/site-packages (from matplotlib->mmdet==2.14.0) (1.3.2)
Requirement already satisfied: pyparsing>=2.2.1 in /opt/conda/lib/python3.7/site-packages (from matplotlib->mmdet==2.14.0) (3.0.6)
Requirement already satisfied: setuptools>=18.0 in /opt/conda/lib/python3.7/site-packages (from pycocotools->mmdet==2.14.0) (59.1.1)
Requirement already satisfied: cython>=0.27.3 in /opt/conda/lib/python3.7/site-packages (from pycocotools->mmdet==2.14.0) (0.29.24)
Requirement already satisfied: torchvision in /opt/conda/lib/python3.7/site-packages (from timm->mmdet==2.14.0) (0.8.0)
Requirement already satisfied: torch>=1.4 in /opt/conda/lib/python3.7/site-packages (from timm->mmdet==2.14.0) (1.7.0+cu110)
Requirement already satisfied: tomli>=1.0.0 in /opt/conda/lib/python3.7/site-packages (from setuptools-scm>=4->matplotlib->mmdet==2.14.0) (1.2.2)
Requirement already satisfied: typing-extensions in /opt/conda/lib/python3.7/site-packages (from torch>=1.4->timm->mmdet==2.14.0) (3.10.0.2)
Requirement already satisfied: dataclasses in /opt/conda/lib/python3.7/site-packages (from torch>=1.4->timm->mmdet==2.14.0) (0.8)
Requirement already satisfied: future in /opt/conda/lib/python3.7/site-packages (from torch>=1.4->timm->mmdet==2.14.0) (0.18.2)
Installing collected packages: mmdet
  Running setup.py develop for mmdet
Successfully installed mmdet-2.14.0
WARNING: Running pip as the 'root' user can result in broken permissions and conflicting behaviour with the system package manager. It is recommended to use a virtual environment instead: https://pip.pypa.io/warnings/venv
/kaggle/working

This is the log for checking the presence of mmdet==2.14.0 using pip show.

Name: mmdet
Version: 2.14.0
Summary: OpenMMLab Detection Toolbox and Benchmark
Home-page: https://github.com/open-mmlab/mmdetection
Author: OpenMMLab
Author-email: openmmlab@gmail.com
License: Apache License 2.0
Location: /opt/conda/lib/python3.7/site-packages/mmdet-2.14.0-py3.7.egg
Requires: matplotlib, numpy, pycocotools, six, terminaltables, timm
Required-by: 

This is however the error when importing mmdet


---------------------------------------------------------------------------
ModuleNotFoundError                       Traceback (most recent call last)
/tmp/ipykernel_35/2570074524.py in <module>
----> 1 import mmdet.version

ModuleNotFoundError: No module named 'mmdet'

Bug fix
If you have already identified the reason, you can provide the information here. If you are willing to create a PR to fix it, please also leave a comment here and that would be much appreciated!

@RangiLyu
Copy link
Member

Notice the warning message:

WARNING: Running pip as the 'root' user can result in broken permissions and conflicting behaviour with the system package manager. It is recommended to use a virtual environment instead: https://pip.pypa.io/warnings/venv
/kaggle/working

Do not use root to install python package. The default python for the root user is different from the one you use.

@lenardxu
Copy link
Author

Notice the warning message:

WARNING: Running pip as the 'root' user can result in broken permissions and conflicting behaviour with the system package manager. It is recommended to use a virtual environment instead: https://pip.pypa.io/warnings/venv
/kaggle/working

Do not use root to install python package. The default python for the root user is different from the one you use.

Thank you for your reply. Maybe I should pay attention to that next time when the similar takes place. Besides that, I've also successfully tried another way (dynamic) to solve it, which is just to insert the directory, where this mmdet module is located, to the system path so that it can be found while running.

@Juin28
Copy link

Juin28 commented Jul 21, 2023

Hi, I have encountered similar issue of no module named "mmdet" when I try to import in visual studio code. The environment information is here.

Python: 3.8.17 (default, Jul 5 2023, 20:44:21) [MSC v.1916 64 bit (AMD64)]
CUDA available: False
numpy_random_seed: 2147483648
GCC: n/a
PyTorch: 2.0.1
PyTorch compiling details: PyTorch built with:

  • C++ Version: 199711
  • MSVC 193431937
  • Intel(R) Math Kernel Library Version 2020.0.2 Product Build 20200624 for Intel(R) 64 architecture applications
  • Intel(R) MKL-DNN v2.7.3 (Git Hash 6dbeffbae1f23cbbeae17adb7b5b13f1f37c080e)
  • OpenMP 2019
  • LAPACK is enabled (usually provided by MKL)
  • CPU capability usage: AVX2
  • Build settings: BLAS_INFO=mkl, BUILD_TYPE=Release, CXX_COMPILER=C:/cb/pytorch_1000000000000/work/tmp_bin/sccache-cl.exe, CXX_FLAGS=/DWIN32 /D_WINDOWS /GR /EHsc /w /bigobj /FS -DUSE_PTHREADPOOL -DNDEBUG -DUSE_KINETO -DLIBKINETO_NOCUPTI -DLIBKINETO_NOROCTRACER -DUSE_FBGEMM -DUSE_XNNPACK -DSYMBOLICATE_MOBILE_DEBUG_HANDLE, LAPACK_INFO=mkl, PERF_WITH_AVX=1, PERF_WITH_AVX2=1, PERF_WITH_AVX512=1, TORCH_DISABLE_GPU_ASSERTS=OFF, TORCH_VERSION=2.0.1, USE_CUDA=0, USE_CUDNN=OFF, USE_EXCEPTION_PTR=1, USE_GFLAGS=OFF, USE_GLOG=OFF, USE_MKL=ON, USE_MKLDNN=ON, USE_MPI=OFF, USE_NCCL=OFF, USE_NNPACK=OFF, USE_OPENMP=ON, USE_ROCM=OFF,

TorchVision: 0.15.2
OpenCV: 4.8.0
MMEngine: 0.8.2
MMDetection: 3.1.0+f78af77

@Suncheng2022
Copy link

Suncheng2022 commented Jul 24, 2023

Hi, I have encountered similar issue of no module named "mmdet" when I try to import in visual studio code. The environment information is here.

Python: 3.8.17 (default, Jul 5 2023, 20:44:21) [MSC v.1916 64 bit (AMD64)] CUDA available: False numpy_random_seed: 2147483648 GCC: n/a PyTorch: 2.0.1 PyTorch compiling details: PyTorch built with:

  • C++ Version: 199711
  • MSVC 193431937
  • Intel(R) Math Kernel Library Version 2020.0.2 Product Build 20200624 for Intel(R) 64 architecture applications
  • Intel(R) MKL-DNN v2.7.3 (Git Hash 6dbeffbae1f23cbbeae17adb7b5b13f1f37c080e)
  • OpenMP 2019
  • LAPACK is enabled (usually provided by MKL)
  • CPU capability usage: AVX2
  • Build settings: BLAS_INFO=mkl, BUILD_TYPE=Release, CXX_COMPILER=C:/cb/pytorch_1000000000000/work/tmp_bin/sccache-cl.exe, CXX_FLAGS=/DWIN32 /D_WINDOWS /GR /EHsc /w /bigobj /FS -DUSE_PTHREADPOOL -DNDEBUG -DUSE_KINETO -DLIBKINETO_NOCUPTI -DLIBKINETO_NOROCTRACER -DUSE_FBGEMM -DUSE_XNNPACK -DSYMBOLICATE_MOBILE_DEBUG_HANDLE, LAPACK_INFO=mkl, PERF_WITH_AVX=1, PERF_WITH_AVX2=1, PERF_WITH_AVX512=1, TORCH_DISABLE_GPU_ASSERTS=OFF, TORCH_VERSION=2.0.1, USE_CUDA=0, USE_CUDNN=OFF, USE_EXCEPTION_PTR=1, USE_GFLAGS=OFF, USE_GLOG=OFF, USE_MKL=ON, USE_MKLDNN=ON, USE_MPI=OFF, USE_NCCL=OFF, USE_NNPACK=OFF, USE_OPENMP=ON, USE_ROCM=OFF,

TorchVision: 0.15.2 OpenCV: 4.8.0 MMEngine: 0.8.2 MMDetection: 3.1.0+f78af77

I got the same problem, too. I fixed it by add import sys sys.path.append('your_absolute_path/mmdetection-main/') to projects/XDecoder/demo.py. Hope it's helpful for you.

Moreover, projects/XDecoder/demo.py may need mmdet/.mim/model-index.yml to run which didn't exist in the dir. I want to run the image caption func of XDecoder.

@Qiangsen-2025
Copy link

Hi, I have encountered similar issue of no module named "mmdet" when I try to import in visual studio code. The environment information is here.
Python: 3.8.17 (default, Jul 5 2023, 20:44:21) [MSC v.1916 64 bit (AMD64)] CUDA available: False numpy_random_seed: 2147483648 GCC: n/a PyTorch: 2.0.1 PyTorch compiling details: PyTorch built with:

  • C++ Version: 199711
  • MSVC 193431937
  • Intel(R) Math Kernel Library Version 2020.0.2 Product Build 20200624 for Intel(R) 64 architecture applications
  • Intel(R) MKL-DNN v2.7.3 (Git Hash 6dbeffbae1f23cbbeae17adb7b5b13f1f37c080e)
  • OpenMP 2019
  • LAPACK is enabled (usually provided by MKL)
  • CPU capability usage: AVX2
  • Build settings: BLAS_INFO=mkl, BUILD_TYPE=Release, CXX_COMPILER=C:/cb/pytorch_1000000000000/work/tmp_bin/sccache-cl.exe, CXX_FLAGS=/DWIN32 /D_WINDOWS /GR /EHsc /w /bigobj /FS -DUSE_PTHREADPOOL -DNDEBUG -DUSE_KINETO -DLIBKINETO_NOCUPTI -DLIBKINETO_NOROCTRACER -DUSE_FBGEMM -DUSE_XNNPACK -DSYMBOLICATE_MOBILE_DEBUG_HANDLE, LAPACK_INFO=mkl, PERF_WITH_AVX=1, PERF_WITH_AVX2=1, PERF_WITH_AVX512=1, TORCH_DISABLE_GPU_ASSERTS=OFF, TORCH_VERSION=2.0.1, USE_CUDA=0, USE_CUDNN=OFF, USE_EXCEPTION_PTR=1, USE_GFLAGS=OFF, USE_GLOG=OFF, USE_MKL=ON, USE_MKLDNN=ON, USE_MPI=OFF, USE_NCCL=OFF, USE_NNPACK=OFF, USE_OPENMP=ON, USE_ROCM=OFF,

TorchVision: 0.15.2 OpenCV: 4.8.0 MMEngine: 0.8.2 MMDetection: 3.1.0+f78af77

I got the same problem, too. I fixed it by add import sys sys.path.append('your_absolute_path/mmdetection-main/') to projects/XDecoder/demo.py. Hope it's helpful for you.

Moreover, projects/XDecoder/demo.py may need mmdet/.mim/model-index.yml to run which didn't exist in the dir. I want to run the image caption func of XDecoder.

I get the same problem, and with you solution, I win, thank you .

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

5 participants