mmdetection: ImportError: /home/user/repos/mmdetection/mmdet/ops/dcn/deform_conv_cuda.cpython-37m-x86_64-linux-gnu.so: undefined symbol: _ZN6caffe26detail37_typeMetaDataInstance_preallocated_32E

Bug occurs either with pip’s versions of pytorch 1.3_cu100+vision_0.4.1_cu100 and buided from sources.

Reproduction

  1. What command or script did you run?
from mmdet.apis import init_detector, inference_detector
  1. Did you make any modifications on the code or config? Did you understand what you have modified? NO

Environment

  • OS: [e.g., Ubuntu 18.04]
  • GCC [e.g., 7.4.0]
  • PyTorch version of master
  • installed PyTorch from sources
  • GPU model [2080]
  • CUDA and CUDNN version 10.0, 7.6.2

Error traceback

/home/user/anaconda3/lib/python3.7/site-packages/torchvision/io/_video_opt.py:17: UserWarning: video reader based on ffmpeg c++ ops not available
  warnings.warn("video reader based on ffmpeg c++ ops not available")
---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
<ipython-input-2-925ef20dc1df> in <module>
----> 1 from mmdet.apis import init_detector, inference_detector
      2 
      3 # Standard output of images from mmdetection is slightly rewritten for some flexibility
      4 from utils.viz import show_result
      5 

~/repos/mmdetection/mmdet/apis/__init__.py in <module>
      1 from .env import get_root_logger, init_dist, set_random_seed
----> 2 from .inference import (inference_detector, init_detector, show_result,
      3                         show_result_pyplot)
      4 from .train import train_detector
      5 

~/repos/mmdetection/mmdet/apis/inference.py in <module>
      9 from mmcv.runner import load_checkpoint
     10 
---> 11 from mmdet.core import get_classes
     12 from mmdet.datasets.pipelines import Compose
     13 from mmdet.models import build_detector

~/repos/mmdetection/mmdet/core/__init__.py in <module>
      4 from .fp16 import *  # noqa: F401, F403
      5 from .mask import *  # noqa: F401, F403
----> 6 from .post_processing import *  # noqa: F401, F403
      7 from .utils import *  # noqa: F401, F403

~/repos/mmdetection/mmdet/core/post_processing/__init__.py in <module>
----> 1 from .bbox_nms import multiclass_nms
      2 from .merge_augs import (merge_aug_bboxes, merge_aug_masks,
      3                          merge_aug_proposals, merge_aug_scores)
      4 
      5 __all__ = [

~/repos/mmdetection/mmdet/core/post_processing/bbox_nms.py in <module>
      1 import torch
      2 
----> 3 from mmdet.ops.nms import nms_wrapper
      4 
      5 

~/repos/mmdetection/mmdet/ops/__init__.py in <module>
      1 from .context_block import ContextBlock
----> 2 from .dcn import (DeformConv, DeformConvPack, DeformRoIPooling,
      3                   DeformRoIPoolingPack, ModulatedDeformConv,
      4                   ModulatedDeformConvPack, ModulatedDeformRoIPoolingPack,
      5                   deform_conv, deform_roi_pooling, modulated_deform_conv)

~/repos/mmdetection/mmdet/ops/dcn/__init__.py in <module>
----> 1 from .deform_conv import (DeformConv, DeformConvPack, ModulatedDeformConv,
      2                           ModulatedDeformConvPack, deform_conv,
      3                           modulated_deform_conv)
      4 from .deform_pool import (DeformRoIPooling, DeformRoIPoolingPack,
      5                           ModulatedDeformRoIPoolingPack, deform_roi_pooling)

~/repos/mmdetection/mmdet/ops/dcn/deform_conv.py in <module>
      7 from torch.nn.modules.utils import _pair
      8 
----> 9 from . import deform_conv_cuda
     10 
     11 

ImportError: /home/user/repos/mmdetection/mmdet/ops/dcn/deform_conv_cuda.cpython-37m-x86_64-linux-gnu.so: undefined symbol: _ZN6caffe26detail37_typeMetaDataInstance_preallocated_32E

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Reactions: 5
  • Comments: 18 (4 by maintainers)

Commits related to this issue

Most upvoted comments

delete the ‘build’ file in mmdetection, then Compile the mmdet again。It works!!

First run “import torch” Source: https://github.com/rusty1s/pytorch_scatter/issues/7

I found a work-around this. Found out torch of version 1.2 works as expected

If you’re using CUDA 9.0 and want to continue using it, you need to downgrade the Pytorch version to 1.1.0 (which uses cudatoolkit version 9.0) and then build again like this:

conda install pytorch==1.1.0 torchvision==0.3.0 cudatoolkit=9.0 -c pytorch
cd mmdetection
rm -rf build
python setup.py develop

NOTE: Installing the default (latest) version of Pytorch (v1.2.0) without specifying the cudatoolkit version will automatically install the latest cudatoolkit (v10.1.0), which means that if you did that you need to downgrade the cudatoolkit and eventually reboot.

I tested with the latest pytorch (pip’s version) and mmdetection, there is no error occurs. Here are my testing commands:

conda create -n mmdet python=3.7
source activate mmdet
conda install ipython
pip install torch torchvision
git clone https://github.com/open-mmlab/mmdetection.git
cd mmdetection
python setup.py build_ext --inplace
export PYTHONPATH=${PWD}:$PYTHONPATH
pip install -r requirements.txt
ipython
from mmdet.apis import init_detector, inference_detector

Here are my environment details:

  • OS: [Ubuntu 18.04]
  • GCC [5.4.0]
  • PyTorch version [1.3.1]
  • installed PyTorch with pip install torch torchvision
  • GPU model [GeForce GTX TITAN X]
  • CUDA and CUDNN version 10.1, 7.6.0
  • nvcc version [10.1.243]
  • nvidia driven version [418.87]

And why I decided check it up?! These lines are not enough, you will get errors. So I corrected them

conda create -n mmdet python=3.7
conda activate mmdet
pip install cython torch torchvision mmcv
git clone https://github.com/open-mmlab/mmdetection.git
cd mmdetection
export PYTHONPATH=${PWD}:$PYTHONPATH
pip install -r requirements.txt
python setup.py build_ext --inplace
python setup.py install
python -c "from mmdet.apis import init_detector, inference_detector"

Facing the same issue. Checkout to v1.0rc0 and downgrade mmcv to 0.2.14 works for me.

Share version you are trying here.

Try to use mmcv 0.2.14 mmdet 1.0rc0 torch 1.3.1
These versions work for me