faster-rcnn.pytorch: Pytorch 1.0 branch ImportError: torch.utils.ffi is deprecated
I followed the instructions for Pytorch 1.0: switched to pytorch-1.0 branch, went to lib and ran python setup.py build develop. Install succeeded with no errors.
However, when I try to import roi_pool in the Python prompt, I get “torch.utils.ffi is deprecated” error. Isn’t this supposed to be fixed in the pytorch-1.0 branch?
Python 3.7.2 (default, Dec 29 2018, 06:19:36)
[GCC 7.3.0] :: Anaconda, Inc. on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from model.roi_pooling.modules import roi_pool
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/remoteuser/faster-rcnn.pytorch/lib/model/roi_pooling/modules/roi_pool.py", line 2, in <module>
from ..functions.roi_pool import RoIPoolFunction
File "/home/remoteuser/faster-rcnn.pytorch/lib/model/roi_pooling/functions/roi_pool.py", line 3, in <module>
from .._ext import roi_pooling
File "/home/remoteuser/faster-rcnn.pytorch/lib/model/roi_pooling/_ext/roi_pooling/__init__.py", line 2, in <module>
from torch.utils.ffi import _wrap_function
File "/home/remoteuser/.miniconda3/envs/outfit/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.
Thank you!
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Reactions: 6
- Comments: 22
@lzxzy confirmed it works. using
git checkout pytorch-1.0will fix your problem.I solved by adding the source code of torch.utils.ffi to my project without changing my pytorch version.(I use torch 1.4.0). For example, save the following code to
ffiext.py, then you can replacefrom torch.utils.ffi import _wrap_functionwithfrom ffiext import _wrap_function. You can also find the following source code from ‘https://s0pytorch0org.icopy.site/docs/0.4.1/_modules/torch/utils/ffi.html’.Yes, it does work for me. Infact, I have successfully trained my model with the new branch. Ensure that you are on the correct branch with
git branch.@zcunyi After cloning the repo, you need to switch to the Pytorch-1.0 branch via
git checkout pytorch-1.0. Then you can proceed with the installation instructions given in the README of pytorch-1.0 branch.@odellus If you look at the setup script
lib/setup.py, it does not call the said file you mentioned. The ROI and NMS files that are used now reside here, source for the same are here. The files you pointed are required for PyTorch < 0.4.1 and have not been deleted from PyTorch 1.0 branch.Closing this issue since it seems it works for others.
@andrewjong @ericsqxd You need to checkout the
pytorch-1.0branch. Themasterbranch supports Pytorch 0.4.