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

FAQ #1601

Closed
zhouzaida opened this issue Dec 20, 2021 · 1 comment
Closed

FAQ #1601

zhouzaida opened this issue Dec 20, 2021 · 1 comment

Comments

@zhouzaida
Copy link
Collaborator

zhouzaida commented Dec 20, 2021

Frequently Asked Questions

We list some common troubles faced by many users and their corresponding solutions here.
Feel free to enrich the list if you find any frequent issues and have ways to help others to solve them.

Installation

  • "No module named 'mmcv.ops'"; "No module named 'mmcv._ext'"

    1. Uninstall existing mmcv in the environment using pip uninstall mmcv
    2. Install mmcv-full following the installation instruction or Build MMCV from source
  • "invalid device function" or "no kernel image is available for execution"

    1. Check the CUDA compute capability of you GPU
    2. Run python mmdet/utils/collect_env.py to check whether PyTorch, torchvision, and MMCV are built for the correct GPU architecture. You may need to set TORCH_CUDA_ARCH_LIST to reinstall MMCV. The compatibility issue could happen when using old GPUS, e.g., Tesla K80 (3.7) on colab.
    3. Check whether the running environment is the same as that when mmcv/mmdet is compiled. For example, you may compile mmcv using CUDA 10.0 bug run it on CUDA9.0 environments
  • "undefined symbol" or "cannot open xxx.so"

    1. If those symbols are CUDA/C++ symbols (e.g., libcudart.so or GLIBCXX), check
      whether the CUDA/GCC runtimes are the same as those used for compiling mmcv
    2. If those symbols are Pytorch symbols (e.g., symbols containing caffe, aten, and TH), check whether the Pytorch version is the same as that used for compiling mmcv
    3. Run python mmdet/utils/collect_env.py to check whether PyTorch, torchvision, and MMCV are built by and running on the same environment
  • "RuntimeError: CUDA error: invalid configuration argument"

    This error may be caused by the poor performance of GPU. Try to decrease the value of THREADS_PER_BLOCK
    and recompile mmcv.

  • "RuntimeError: nms is not compiled with GPU support"

    This error is because your CUDA environment is not installed correctly.
    You may try to re-install your CUDA environment and then delete the build/ folder before re-compile mmcv.

  • "Segmentation fault"

    1. Check your GCC version and use GCC >= 5.4. This usually caused by the incompatibility between PyTorch and the environment (e.g., GCC < 4.9 for PyTorch). We also recommend the users to avoid using GCC 5.5 because many feedbacks report that GCC 5.5 will cause "segmentation fault" and simply changing it to GCC 5.4 could solve the problem
    2. Check whether PyTorch is correctly installed and could use CUDA op, e.g. type the following command in your terminal and see whether they could correctly output results
      python -c 'import torch; print(torch.cuda.is_available())'
    3. If PyTorch is correctly installed, check whether MMCV is correctly installed. If MMCV is correctly installed, then there will be no issue of the command
      python -c 'import mmcv; import mmcv.ops'
    4. If MMCV and PyTorch are correctly installed, you can use ipdb to set breakpoints or directly add print to debug and see which part leads the segmentation fault
  • "libtorch_cuda_cu.so: cannot open shared object file"

    mmcv-full depends on the share object but it can not be found. We can check whether the object exists in ~/miniconda3/envs/{environment-name}/lib/python3.7/site-packages/torch/lib or try to re-install the PyTorch.

  • "fatal error C1189: #error: -- unsupported Microsoft Visual Studio version!"

    If you are building mmcv-full on Windows and the version of CUDA is 9.2, you will probably encounter the error "C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v9.2\include\crt/host_config.h(133): fatal error C1189: #error: -- unsupported Microsoft Visual Studio version! Only the versions 2012, 2013, 2015 and 2017 are supported!", in which case you can use a lower version of Microsoft Visual Studio like vs2017.

  • "error: member "torch::jit::detail::ModulePolicy::all_slots" may not be initialized"

    If your version of PyTorch is 1.5.0 and you are building mmcv-full on Windows, you will probably encounter the error - torch/csrc/jit/api/module.h(474): error: member "torch::jit::detail::ModulePolicy::all_slots" may not be initialized. The way to solve the error is to replace all the static constexpr bool all_slots = false; with static bool all_slots = false; at this file https://github.com/pytorch/pytorch/blob/v1.5.0/torch/csrc/jit/api/module.h. More details can be found at member "torch::jit::detail::AttributePolicy::all_slots" may not be initialized pytorch/pytorch#39394.

  • "error: a member with an in-class initializer must be const"

    If your version of PyTorch is 1.6.0 and you are building mmcv-full on Windows, you will probably encounter the error "- torch/include\torch/csrc/jit/api/module.h(483): error: a member with an in-class initializer must be const". The way to solve the error is to replace all the CONSTEXPR_EXCEPT_WIN_CUDA with const at torch/include\torch/csrc/jit/api/module.h. More details can be found at Can't install mmcv-full. Reported 'Ninja: build stopped: subcommand failed' #575.

  • "error: member "torch::jit::ProfileOptionalOp::Kind" may not be initialized"

    If your version of PyTorch is 1.7.0 and you are building mmcv-full on Windows, you will probably encounter the error torch/include\torch/csrc/jit/ir/ir.h(1347): error: member "torch::jit::ProfileOptionalOp::Kind" may not be initialized. The way to solve the error needs to modify several local files of PyTorch:

    • delete static constexpr Symbol Kind = ::c10::prim::profile; and tatic constexpr Symbol Kind = ::c10::prim::profile_optional; at torch/include\torch/csrc/jit/ir/ir.h
    • replace explicit operator type&() { return *(this->value); } with explicit operator type&() { return *((type*)this->value); } at torch\include\pybind11\cast.h
    • replace all the CONSTEXPR_EXCEPT_WIN_CUDA with const at torch/include\torch/csrc/jit/api/module.h
  • Compatibility issue between MMCV and MMDetection; "ConvWS is already registered in conv layer"

    Please install the correct version of MMCV for the version of your MMDetection following the installation instruction. More details can be found at [cpp-extensions] Ensure default extra_compile_args pytorch/pytorch#45956.

Usage

@zhouzaida zhouzaida pinned this issue Dec 20, 2021
@imabackstabber imabackstabber unpinned this issue Mar 9, 2022
@imabackstabber imabackstabber pinned this issue Mar 9, 2022
@zhouzaida zhouzaida unpinned this issue Nov 17, 2022
@qiyueliuhuo
Copy link

When I run " python3 -c 'import mmcv; import mmcv.ops' "
obtain:
[1] 505708 segmentation fault (core dumped) python3 -c 'import mmcv; import mmcv.ops'

min list|grep mmcv

mmcv-full 1.7.0 https://github.com/open-mmlab/mmcv

How to solve it ?

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

2 participants