CenterNet
CenterNet copied to clipboard
ImportError: torch.utils.ffi is deprecated. Please use cpp extensions instead.
During DCNv2 compilation, I encountered this ImportError and I have already identified the reason (PyTorch 1.0.0+ has changed API name). Would you mind add a PyTorch version check conditional branch to fix this issue? Thanks in advance.
The complete Traceback is pasted bellow:
/home/lan/Documents/xuyinda/Projects/CenterNet/src/lib/models/networks/DCNv2
Traceback (most recent call last):
File "build.py", line 3, in <module>
from torch.utils.ffi import create_extension
File "/home/lan/anaconda3/envs/open-mmlab/lib/python3.7/site-packages/torch/utils/ffi/__init__.py", line 1, in <module>
raise ImportError("torch.utils.ffi is deprecated. Please use cpp extensions instead.")
ImportError: torch.utils.ffi is deprecated. Please use cpp extensions instead.
Traceback (most recent call last):
File "build_double.py", line 3, in <module>
from torch.utils.ffi import create_extension
File "/home/lan/anaconda3/envs/open-mmlab/lib/python3.7/site-packages/torch/utils/ffi/__init__.py", line 1, in <module>
raise ImportError("torch.utils.ffi is deprecated. Please use cpp extensions instead.")
ImportError: torch.utils.ffi is deprecated. Please use cpp extensions instead.
[UPDATE] With the following conditional branch, the import issue was fixed.
from pkg_resources import parse_version
if parse_version(torch.__version__) >= parse_version("1.0.0"):
from torch.utils.cpp_extension import BuildExtension as create_extension
else:
from torch.utils.ffi import create_extension
However, I encountered new issue which throws "TypeError: dist must be a Distribution instance". This issue seems to be unfixable by simply change the imported API.
The complete traceback is pasted as below.
/home/lan/Documents/xuyinda/Projects/CenterNet/src/lib/models/networks/DCNv2
Including CUDA code.
/home/lan/Documents/xuyinda/Projects/CenterNet/src/lib/models/networks/DCNv2
Traceback (most recent call last):
File "build.py", line 44, in <module>
extra_compile_args=extra_compile_args
File "/home/lan/anaconda3/envs/open-mmlab/lib/python3.7/site-packages/torch/utils/cpp_extension.py", line 234, in __init__
super(BuildExtension, self).__init__(*args, **kwargs)
File "/home/lan/anaconda3/envs/open-mmlab/lib/python3.7/site-packages/setuptools/__init__.py", line 163, in __init__
_Command.__init__(self, dist)
File "/home/lan/anaconda3/envs/open-mmlab/lib/python3.7/distutils/cmd.py", line 57, in __init__
raise TypeError("dist must be a Distribution instance")
TypeError: dist must be a Distribution instance
Including CUDA code.
/home/lan/Documents/xuyinda/Projects/CenterNet/src/lib/models/networks/DCNv2
Traceback (most recent call last):
File "build_double.py", line 44, in <module>
extra_compile_args=extra_compile_args
File "/home/lan/anaconda3/envs/open-mmlab/lib/python3.7/site-packages/torch/utils/cpp_extension.py", line 234, in __init__
super(BuildExtension, self).__init__(*args, **kwargs)
File "/home/lan/anaconda3/envs/open-mmlab/lib/python3.7/site-packages/setuptools/__init__.py", line 163, in __init__
_Command.__init__(self, dist)
File "/home/lan/anaconda3/envs/open-mmlab/lib/python3.7/distutils/cmd.py", line 57, in __init__
raise TypeError("dist must be a Distribution instance")
TypeError: dist must be a Distribution instance
Hi, I installed torch=0.4.1. However, there is another error: Bus error (core dumped). Do you know how to fix this?
I have the same problem... Have there been solutions for this issue in pytorch 1.0+?
Thanks~
@EricKani @neoyang0620 Solved by this issue
@MARMOTatZJU Thank you~
[UPDATE] With the following conditional branch, the import issue was fixed.
from pkg_resources import parse_version if parse_version(torch.__version__) >= parse_version("1.0.0"): from torch.utils.cpp_extension import BuildExtension as create_extension else: from torch.utils.ffi import create_extension
However, I encountered new issue which throws "TypeError: dist must be a Distribution instance". This issue seems to be unfixable by simply change the imported API.
The complete traceback is pasted as below.
/home/lan/Documents/xuyinda/Projects/CenterNet/src/lib/models/networks/DCNv2 Including CUDA code. /home/lan/Documents/xuyinda/Projects/CenterNet/src/lib/models/networks/DCNv2 Traceback (most recent call last): File "build.py", line 44, in <module> extra_compile_args=extra_compile_args File "/home/lan/anaconda3/envs/open-mmlab/lib/python3.7/site-packages/torch/utils/cpp_extension.py", line 234, in __init__ super(BuildExtension, self).__init__(*args, **kwargs) File "/home/lan/anaconda3/envs/open-mmlab/lib/python3.7/site-packages/setuptools/__init__.py", line 163, in __init__ _Command.__init__(self, dist) File "/home/lan/anaconda3/envs/open-mmlab/lib/python3.7/distutils/cmd.py", line 57, in __init__ raise TypeError("dist must be a Distribution instance") TypeError: dist must be a Distribution instance Including CUDA code. /home/lan/Documents/xuyinda/Projects/CenterNet/src/lib/models/networks/DCNv2 Traceback (most recent call last): File "build_double.py", line 44, in <module> extra_compile_args=extra_compile_args File "/home/lan/anaconda3/envs/open-mmlab/lib/python3.7/site-packages/torch/utils/cpp_extension.py", line 234, in __init__ super(BuildExtension, self).__init__(*args, **kwargs) File "/home/lan/anaconda3/envs/open-mmlab/lib/python3.7/site-packages/setuptools/__init__.py", line 163, in __init__ _Command.__init__(self, dist) File "/home/lan/anaconda3/envs/open-mmlab/lib/python3.7/distutils/cmd.py", line 57, in __init__ raise TypeError("dist must be a Distribution instance") TypeError: dist must be a Distribution instance
I have the same issue. Do you know how to fix it now?
I am still having this same issue. Anyone found solution for this?
Until 9/9/2021, you can refer to the repo here https://github.com/jinfagang/DCNv2_latest I already checked it. Note that, remove the "sudo" before the python in make.sh if you can't run the sh script because torch is not found.
Until 9/9/2021, you can refer to the repo here https://github.com/jinfagang/DCNv2_latest I already checked it. Note that, remove the "sudo" before the python in make.sh if you can't run the sh script because torch is not found.
Thank you, this work for me