question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

ImportError: cannot import name 'MultiScaleDeformableAttention' from 'mmcv.cnn.bricks.transformer'

See original GitHub issue

Thanks for reporting the unexpected results 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.
  3. The unexpected results still exist in the latest version.

Describe the Issue

/home/zuppif/integration-object-detection-icevision/.venv/lib/python3.9/site-packages/mmcv/cnn/bricks/transformer.py:28: UserWarning: Fail to import ``MultiScaleDeformableAttention`` from ``mmcv.ops.multi_scale_deform_attn``, You should install ``mmcv-full`` if you need this module. 
  warnings.warn('Fail to import ``MultiScaleDeformableAttention`` from '
/home/zuppif/integration-object-detection-icevision/.venv/lib/python3.9/site-packages/mmdet/models/utils/transformer.py:26: UserWarning: `MultiScaleDeformableAttention` in MMCV has been moved to `mmcv.ops.multi_scale_deform_attn`, please update your MMCV
  warnings.warn(
Traceback (most recent call last):
  File "/home/zuppif/integration-object-detection-icevision/.venv/lib/python3.9/site-packages/mmdet/models/utils/transformer.py", line 23, in <module>
    from mmcv.ops.multi_scale_deform_attn import MultiScaleDeformableAttention
  File "/home/zuppif/integration-object-detection-icevision/.venv/lib/python3.9/site-packages/mmcv/ops/__init__.py", line 2, in <module>
    from .ball_query import ball_query
  File "/home/zuppif/integration-object-detection-icevision/.venv/lib/python3.9/site-packages/mmcv/ops/ball_query.py", line 7, in <module>
    ext_module = ext_loader.load_ext('_ext', ['ball_query_forward'])
  File "/home/zuppif/integration-object-detection-icevision/.venv/lib/python3.9/site-packages/mmcv/utils/ext_loader.py", line 13, in load_ext
    ext = importlib.import_module('mmcv.' + name)
  File "/home/zuppif/miniconda3/lib/python3.9/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
ImportError: /home/zuppif/integration-object-detection-icevision/.venv/lib/python3.9/site-packages/mmcv/_ext.cpython-39-x86_64-linux-gnu.so: undefined symbol: _ZNK2at6Tensor6deviceEv

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/zuppif/integration-object-detection-icevision/notebook.py", line 7, in <module>
    from icevision import ObjectDetectionRecord, Parser, ClassMap, BBox, ImgSize
  File "/home/zuppif/integration-object-detection-icevision/.venv/lib/python3.9/site-packages/icevision/__init__.py", line 7, in <module>
    from icevision import models
  File "/home/zuppif/integration-object-detection-icevision/.venv/lib/python3.9/site-packages/icevision/models/__init__.py", line 15, in <module>
    from icevision.models import mmdet
  File "/home/zuppif/integration-object-detection-icevision/.venv/lib/python3.9/site-packages/icevision/models/mmdet/__init__.py", line 1, in <module>
    from icevision.models.mmdet import common
  File "/home/zuppif/integration-object-detection-icevision/.venv/lib/python3.9/site-packages/icevision/models/mmdet/common/__init__.py", line 3, in <module>
    from icevision.models.mmdet.common import bbox
  File "/home/zuppif/integration-object-detection-icevision/.venv/lib/python3.9/site-packages/icevision/models/mmdet/common/bbox/__init__.py", line 1, in <module>
    from icevision.models.mmdet.common.bbox.dataloaders import *
  File "/home/zuppif/integration-object-detection-icevision/.venv/lib/python3.9/site-packages/icevision/models/mmdet/common/bbox/dataloaders.py", line 10, in <module>
    from icevision.models.mmdet.common.utils import convert_background_from_zero_to_last
  File "/home/zuppif/integration-object-detection-icevision/.venv/lib/python3.9/site-packages/icevision/models/mmdet/common/utils.py", line 11, in <module>
    from mmdet.models import build_detector
  File "/home/zuppif/integration-object-detection-icevision/.venv/lib/python3.9/site-packages/mmdet/models/__init__.py", line 2, in <module>
    from .backbones import *  # noqa: F401,F403
  File "/home/zuppif/integration-object-detection-icevision/.venv/lib/python3.9/site-packages/mmdet/models/backbones/__init__.py", line 2, in <module>
    from .csp_darknet import CSPDarknet
  File "/home/zuppif/integration-object-detection-icevision/.venv/lib/python3.9/site-packages/mmdet/models/backbones/csp_darknet.py", line 11, in <module>
    from ..utils import CSPLayer
  File "/home/zuppif/integration-object-detection-icevision/.venv/lib/python3.9/site-packages/mmdet/models/utils/__init__.py", line 16, in <module>
    from .transformer import (DetrTransformerDecoder, DetrTransformerDecoderLayer,
  File "/home/zuppif/integration-object-detection-icevision/.venv/lib/python3.9/site-packages/mmdet/models/utils/transformer.py", line 29, in <module>
    from mmcv.cnn.bricks.transformer import MultiScaleDeformableAttention
ImportError: cannot import name 'MultiScaleDeformableAttention' from 'mmcv.cnn.bricks.transformer' (/home/zuppif/integration-object-detection-icevision/.venv/lib/python3.9/site-packages/mmcv/cnn/bricks/transformer.py)

Reproduction

Install mmcv-full using mim or

pip install mmcv-full -f https://download.openmmlab.com/mmcv/dist/cu102/torch1.9.1/index.html

then try to use vfnet

Environment

  1. Please run python -c "from mmcv.utils import collect_env; print(collect_env())" to collect necessary environment information
    It results in an error
 python -c "from mmcv.utils import collect_env; print(collect_env())"
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/home/zuppif/integration-object-detection-icevision/.venv/lib/python3.9/site-packages/mmcv/utils/env.py", line 87, in collect_env
    from mmcv.ops import get_compiler_version, get_compiling_cuda_version
  File "/home/zuppif/integration-object-detection-icevision/.venv/lib/python3.9/site-packages/mmcv/ops/__init__.py", line 2, in <module>
    from .ball_query import ball_query
  File "/home/zuppif/integration-object-detection-icevision/.venv/lib/python3.9/site-packages/mmcv/ops/ball_query.py", line 7, in <module>
    ext_module = ext_loader.load_ext('_ext', ['ball_query_forward'])
  File "/home/zuppif/integration-object-detection-icevision/.venv/lib/python3.9/site-packages/mmcv/utils/ext_loader.py", line 13, in load_ext
    ext = importlib.import_module('mmcv.' + name)
  File "/home/zuppif/miniconda3/lib/python3.9/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
ImportError: /home/zuppif/integration-object-detection-icevision/.venv/lib/python3.9/site-packages/mmcv/_ext.cpython-39-x86_64-linux-gnu.so: undefined symbol: _ZNK2at6Tensor6deviceEv

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:16 (5 by maintainers)

github_iconTop GitHub Comments

3reactions
Matesanzcommented, May 24, 2022

The problem is that ImportError in this line in is silently catching another exception rather than the “install mmcv-full” one.

if you try the line that is raising the Error:

from mmcv.ops.multi_scale_deform_attn import MultiScaleDeformableAttention
>>> ImportError: .../lib/python3.9/site-packages/mmcv/_ext.cpython-39-x86_64-linux-gnu.so: undefined symbol: _ZNK2at6Tensor4add_ERKS0_RKN3c106ScalarE

Solution

For me was install mmcv CPU version:

pip install mmcv-full -f https://download.openmmlab.com/mmcv/dist/cpu/torch1.11.0/index.html
0reactions
howardchinacommented, Dec 6, 2022

same question, why always the same question?

terminal: python3 -m pip list | grep mmcv-full mmcv-full 1.7.0

error: “/home/data/programs/miniconda3/envs/openmmlab/lib/python3.8/site-packages/mmcv/c nn/bricks/transformer.py:33: UserWarning: Fail to import MultiScaleDeformableA ttention from mmcv.ops.multi_scale_deform_attn, You should install mmcv- full if you need this module.”

Read more comments on GitHub >

github_iconTop Results From Across the Web

mmdet.models.utils.transformer - MMDetection's documentation!
Source code for mmdet.models.utils.transformer ... please update your MMCV') from mmcv.cnn.bricks.transformer import MultiScaleDeformableAttention.
Read more >
Transformer: Error importing packages. "ImportError: cannot ...
Change the torch version in colab by running this command !pip install torch==1.4.0. Then, It worked for me.
Read more >
python/open-mmlab/mmcv/mmcv/cnn/bricks/transformer.py
Copyright (c) OpenMMLab. All rights reserved. import copy import math import warnings from typing import Sequence import torch import torch.nn as nn import...
Read more >
解决No module named 'mmcv.cnn.weight_init'的问题
前言:之前1.0+版本mmdetection的时候,对于使用mmcv,需要git clone mmcv的库下来,然后pip到内置的package里。但是到了2.0版本的出现, ...
Read more >
mmcv - bytemeta
ImportError : cannot import name 'MultiScaleDeformableAttention' from 'mmcv.cnn.bricks.transformer'. xiexinch. xiexinch CLOSED · Updated 4 months ago ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found