open-mmlab / mmcv

OpenMMLab Computer Vision Foundation
https://mmcv.readthedocs.io/en/latest/
Apache License 2.0
5.88k stars 1.64k forks source link

UserWarning: Fail to import ``MultiScaleDeformableAttention`` from ``mmcv.ops.multi_scale_deform_attn``, You should install ``mmcv-full`` if you need this module. #1975

Closed KeranLi closed 2 years ago

KeranLi commented 2 years ago

After installing mmcv flowing all guiding, I used code

**_import torch, torchvision import mmcv from mmgen.apis import init_model, sample_unconditional_model

指定 config配置文件路径

config_file = 'configs/styleganv2/stylegan2_c2_lsun-church_256_b4x8_800k.py'

指定预训练模型权重文件路径

checkpoint_file = 'https://download.openmmlab.com/mmgen/stylegan2/official_weights/stylegan2-church-config-f-official_20210327_172657-1d42b7d1.pth'

初始化generatvie

model = init_model(config_file, checkpoint_file, device='cuda:0')

生成图像测试

fake_imgs = sample_unconditional_model(model, 4) fakeimgs.shape**

like the up主@同济子豪君 do in the vedio.

However, I got the error:

*_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 ' Traceback (most recent call last): File "F:/code/openmmlab/basic_install.py", line 5, in from mmgen.apis import init_model, sample_unconditional_model File "F:\code\openmmlab\mmgen\apis__init.py", line 2, in from .inference import (init_model, sample_conditional_model, File "F:\code\openmmlab\mmgen\apis\inference.py", line 9, in from mmgen.models import BaseTranslationModel, build_model File "F:\code\openmmlab\mmgen\models\init__.py", line 2, in from .architectures import # noqa: F401, F403 File "F:\code\openmmlab\mmgen\models\architectures__init.py", line 20, in from .stylegan import (MSStyleGAN2Discriminator, MSStyleGANv2Generator, File "F:\code\openmmlab\mmgen\models\architectures\stylegan__init.py", line 2, in from .generator_discriminator_v1 import (StyleGAN1Discriminator, File "F:\code\openmmlab\mmgen\models\architectures\stylegan\generator_discriminator_v1.py", line 14, in from mmgen.models.architectures.stylegan.modules import Blur File "F:\code\openmmlab\mmgen\models\architectures\stylegan\modules\init.py", line 2, in from .styleganv2_modules import (Blur, ConstantInput, ModulatedConv2d, File "F:\code\openmmlab\mmgen\models\architectures\stylegan\modules\styleganv2_modules.py", line 11, in from mmcv.ops.fused_bias_leakyrelu import (FusedBiasLeakyReLU, File "F:\Anaconda3\envs\openmmlab\lib\site-packages\mmcv\ops\init__.py", line 2, in from .active_rotated_filter import active_rotated_filter File "F:\Anaconda3\envs\openmmlab\lib\site-packages\mmcv\ops\active_rotated_filter.py", line 10, in ['active_rotated_filter_forward', 'active_rotated_filter_backward']) File "F:\Anaconda3\envs\openmmlab\lib\site-packages\mmcv\utils\ext_loader.py", line 13, in load_ext ext = importlib.import_module('mmcv.' + name) File "F:\Anaconda3\envs\openmmlab\lib\importlib\init__.py", line 127, in import_module return _bootstrap._gcdimport(name[level:], package, level) ImportError: DLL load failed: 找不到指定的模块。**

I used the same RTX3060 and CUDA11.2 like @同济子豪君. ![Uploading error.jpg…]()

teamwong111 commented 2 years ago

You should install mmcv-full. You can install mmcv-full according to https://mmcv.readthedocs.io/en/latest/get_started/installation.html

lcg-np commented 9 months ago

I have the same problem: Fail to import MultiScaleDeformableAttention from mmcv.ops.multi_scale_deform_attn, You should install mmcv rather than mmcv-lite if you need this module. and DLL load failed while importing _ext: 找不到指定的程序。

madtunebk commented 4 months ago

mim install 'mmcv-full' -U , it will take a while to compile but it will fix it , also dont use python above 3.11 beacause will fail again.