mirror of
https://github.com/TencentARC/GFPGAN.git
synced 2026-02-17 14:54:38 +00:00
ImportError: No module named 'deform_conv' #27
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @EndeCC0 on GitHub (Jul 17, 2021).
I run Quick Inference after I finish the installation:
"python inference_gfpgan_full.py --model_path experiments/pretrained_models/GFPGANv1.pth --test_path inputs/cropped_faces --aligned".
Then I encountered the following error:
`(GFPGAN) D:\Profession\Git\GFPGAN>python inference_gfpgan_full.py --model_path experiments/pretrained_models/GFPGANv1.pth --test_path inputs/cropped_faces --aligned
----compiler_info: 用于 x86 的 Microsoft (R) C/C++ 优化编译器 19.16.27045 版
版权所有(C) Microsoft Corporation。保留所有权利。
用法: cl [ 选项... ] 文件名... [ /link 链接选项... ]
----match: <re.Match object; span=(35, 46), match='19.16.27045'>
Traceback (most recent call last):
File "D:\Profession\ProgramData\Anaconda3\envs\GFPGAN\lib\site-packages\basicsr\ops\dcn\deform_conv.py", line 10, in
from . import deform_conv_ext
ImportError: cannot import name 'deform_conv_ext' from 'basicsr.ops.dcn' (D:\Profession\ProgramData\Anaconda3\envs\GFPGAN\lib\site-packages\basicsr\ops\dcn_init_.py)
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "inference_gfpgan_full.py", line 10, in
from archs.gfpganv1_arch import GFPGANv1
File "D:\Profession\Git\GFPGAN\archs_init_.py", line 4, in
from basicsr.utils import scandir
File "D:\Profession\ProgramData\Anaconda3\envs\GFPGAN\lib\site-packages\basicsr_init_.py", line 3, in
from .archs import *
File "D:\Profession\ProgramData\Anaconda3\envs\GFPGAN\lib\site-packages\basicsr\archs_init_.py", line 16, in
arch_modules = [importlib.import_module(f'basicsr.archs.{file_name}') for file_name in arch_filenames]
File "D:\Profession\ProgramData\Anaconda3\envs\GFPGAN\lib\site-packages\basicsr\archs_init.py", line 16, in
arch_modules = [importlib.import_module(f'basicsr.archs.{file_name}') for file_name in arch_filenames]
File "D:\Profession\ProgramData\Anaconda3\envs\GFPGAN\lib\importlib_init.py", line 127, in import_module
return _bootstrap.gcd_import(name[level:], package, level)
File "D:\Profession\ProgramData\Anaconda3\envs\GFPGAN\lib\site-packages\basicsr\archs\edsr_arch.py", line 4, in
from basicsr.archs.arch_util import ResidualBlockNoBN, Upsample, make_layer
File "D:\Profession\ProgramData\Anaconda3\envs\GFPGAN\lib\site-packages\basicsr\archs\arch_util.py", line 8, in
from basicsr.ops.dcn import ModulatedDeformConvPack, modulated_deform_conv
File "D:\Profession\ProgramData\Anaconda3\envs\GFPGAN\lib\site-packages\basicsr\ops\dcn_init.py", line 1, in
from .deform_conv import (DeformConv, DeformConvPack, ModulatedDeformConv, ModulatedDeformConvPack, deform_conv,
File "D:\Profession\ProgramData\Anaconda3\envs\GFPGAN\lib\site-packages\basicsr\ops\dcn\deform_conv.py", line 22, in
os.path.join(module_path, 'src', 'deform_conv_cuda_kernel.cu'),
File "D:\Profession\ProgramData\Anaconda3\envs\GFPGAN\lib\site-packages\torch\utils\cpp_extension.py", line 983, in load
keep_intermediates=keep_intermediates)
File "D:\Profession\ProgramData\Anaconda3\envs\GFPGAN\lib\site-packages\torch\utils\cpp_extension.py", line 1199, in _jit_compile
return _import_module_from_library(name, build_directory, is_python_module)
File "D:\Profession\ProgramData\Anaconda3\envs\GFPGAN\lib\site-packages\torch\utils\cpp_extension.py", line 1546, in _import_module_from_library
file, path, description = imp.find_module(module_name, [path])
File "D:\Profession\ProgramData\Anaconda3\envs\GFPGAN\lib\imp.py", line 296, in find_module
raise ImportError(_ERR_MSG.format(name), name=name)
ImportError: No module named 'deform_conv'`
I found that someone had the same problem as me, but it didn’t solve it.
Is there a solution to this ERROR?Thanks for the ANY HELP~
@EndeCC0 commented on GitHub (Jul 17, 2021):
SO... Can this program really run on win10? (confused)
@EndeCC0 commented on GitHub (Jul 17, 2021):
One more thing... I have added env variable BASICSR_EXT=True and BASICSR_JIT=True.
@woctezuma commented on GitHub (Jul 17, 2021):
Do you have a GPU?
Your problem arises here:
16849ceb56/basicsr/ops/dcn/deform_conv.py (L9-L24)which should not be an issue after installation:
f2d3510bf7/setup.py (L117-L137)@EndeCC0 commented on GitHub (Jul 17, 2021):
Of course, RTX2080Ti.
But I need to install gcc? I see that BasicSR seems to need this.
@woctezuma commented on GitHub (Jul 17, 2021):
Maybe one of these: https://github.com/xinntao/BasicSR/issues/280, https://github.com/xinntao/BasicSR/issues/392, https://github.com/xinntao/BasicSR/issues/410, https://github.com/xinntao/BasicSR/issues/416.
@EndeCC0 commented on GitHub (Jul 17, 2021):
OK! I will watch these and try to resolve this error. Thank you for your help anyway.
@EndeCC0 commented on GitHub (Jul 17, 2021):
After unremitting efforts, I am getting closer and closer to their error... (i don't know whether to laugh or cry.)
Now, I encountered the error that cannot import name 'deform_conv_ext' from 'basicsr.ops.dcn'
The following is the complete error:
I saw Xintao said that we should run "python setup.py develop" before import it.
But I have used "pip install basicsr" with BASICSR_EXT=True and BASICSR_JIT=True, And I have gcc 8.1 now. Doesn't it work?
If I want to do same things like he said. I download BasicSR and run "python setup.py develop"... Is it related to GFPGAN?
Please treat me as a fool and tell me how to do it, like "one, two, three, four steps". Grateful for ANY HELP.
@xinntao commented on GitHub (Jul 17, 2021):
@EndeCC0 I have not tested on Win10.
Maybe you could try the JIT
BASICSR_EXT=False python setup.py developBASICSR_JIT=True python xxxx (the cmd), and to see what error it raise~@EndeCC0 commented on GitHub (Jul 17, 2021):
OK, I will try.
@EndeCC0 commented on GitHub (Jul 17, 2021):
When the previous BASICSR remains in the envs, run "python setup.py develop" witn ASICSR_EXT=False. The following error raised.
python setup.py develop
The following error raised when running commands in GPFGAN with BASICSR_JIT=True.
GPFGAN
After reinstalling BASICSR in the envs, run the code. The following error raised.
python setup.py develop
Same error raised when running commands in GPFGAN.
GPFGAN
I'm sorry to bother you with so many errors, the errors in GPFGAN are still the same as in the past.
@EndeCC0 commented on GitHub (Jul 17, 2021):
Very strange, in order to solve the error of not finding cl, I installed vs2017 and configured it in the system environment. But the error shows vs2019.
@xinntao commented on GitHub (Jul 17, 2021):
The basicsr should not compile the dcn when you set the BASICSR_EXT=False
It may be because the different usage of detecting env variables.

Please try to modify the setup.py file in the BasicSR:
Then, run
python setup.py developBTW,
I do not know how to compile cuda extensions in windows. You may google it.
The above try is aiming to use the cuda JIT compilation~ So, during install BasicSR, no compilation should occur.
@woctezuma commented on GitHub (Jul 17, 2021):
Maybe helpful: https://github.com/xinntao/BasicSR/issues/279
@EndeCC0 commented on GitHub (Jul 17, 2021):
Thanks for your answers, I will continue to try. It really doesn't work, I can learn to use linux, there is too much to learn. (laugh)
@xinntao commented on GitHub (Sep 17, 2021):
@ntquyen11 What env do you use?
and you may need to put more information/error log here
@maliho0803 commented on GitHub (May 11, 2022):
nvcr.io/nvidia/pytorch:20.11-py3
using this docker image, everything is ok!!!