New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
torch.utils.ffi is deprecated. How do I use cpp extensions instead? #15645
Comments
Take a look at https://pytorch.org/tutorials/advanced/cpp_extension.html |
so there is no easy solution to this? it looks like it requires a full revamp of the code that used to work for pytorch <= 0.4.1 |
Unfortunately yes. An example port of some other ffi code is at pytorch/audio@8a41ecd but some rewriting is necessary. Let us know if you need help. |
damn, weeks of work to the trash... do you plan on deprecating such low-level stuff on a regular basis or is it really worth it trying to make a cpp extension now ? |
@aliutkus we deprecated the feature after 1.5 years, and we really apologize for not having a structured deprecation path for it (it was technically not possible). We dont plan to deprecate any public API on a regular basis, especially without deprecation warnings over a few releases. This was a special case, and we apologize. |
ok, great. Well I guess it's time to switch from C to C++ =) thanks for all the work |
You should change it as "import torch.utils.cpp_extension" |
The problem is related to the version of pytorch you installed. I reduced its version from 1.0 to 0.4, and the problem is solved. Newer is not better! |
I am using torch version 1.4.0 but I got the same issue how can I solve it? |
Same, I tried |
NOTE THE FOLLOWING SOLUTION WILL ENABLE YOU TO WORK WITH HIGHER VERSION OF PYTORCH WITHOUT NECESSARILY NEEDING TO DOWNGRADE this solution is found here https://blog.csdn.net/weixin_44493291/article/details/113097883 but I just translate know that torch.utils.ffi is a module for pytorch 0.4, later versions of pytorch ceased to include this module If the proplem is related to create_extension, then do the following from torch.utils.ffi import create_extension change the above line to: Also do the following on the code where you see the following: If the error is about _wrap_function then do the following So the code is the following `import os try: if cffi.version_info < (1, 4, 0): def _generate_typedefs():
_cffi_to_torch = {} PY_MODULE_TEMPLATE = Template(""" all = [] _import_symbols(locals()) def _setup_wrapper(with_cuda):
def _create_module_dir(base_path, fullname): def _build_extension(ffi, cffi_wrapper_name, target_dir, verbose): def _make_python_wrapper(name, cffi_wrapper_name, target_dir): def create_extension(name, headers, sources, verbose=True, with_cuda=False,
def _wrap_function(function, ffi): |
This link has a good solution (use google translate if you dont know the meaning) |
After I canged line. I am getting |
I have a similar problem. But I could not use this solution. Can you help me? |
Hi, do you solved thsii problem? |
Hi, no I could not solve that problem. I changed the version of Pytorch. |
This worked for me. |
I have this error. Please help me! File "C:\Users\Murtaza\Desktop\TDAN-VSR-CVPR-2020-master\build.py", line 3, in ModuleNotFoundError: No module named 'torch.utils.ffi' |
🐛 Bug
Trying to build code with a current pytorch under conda fails with the following error:
To Reproduce
Steps to reproduce the behavior:
On Ubuntu 16.04 x64, download and install anaconda
Create an environment and install pytorch there:
conda install -c pytorch pytorch
Follow the instructions to try running this code: https://github.com/ruotianluo/pytorch-faster-rcnn
Get to the
./make.sh
part.Get a
ImportError: torch.utils.ffi is deprecated. Please use cpp extensions instead.
errorExpected behavior
./make.sh
building all the code cleanlyEnvironment
The text was updated successfully, but these errors were encountered: