ImportError : torch.utils.ffi is deprecated. Please use cpp extensions instead

username: mustafa_emre_dos
cooked: <p>My Code =</p>
<p>from torch.utils.ffi import _wrap_function<br>
from .__ext import lib as _lib, ffi as _ffi</p>
<p><strong>all</strong> = []<br>
def _import_symbols(locals):<br>
for symbol in dir(_lib):<br>
fn = getattr(_lib, symbol)<br>
if callable(fn):<br>
locals[symbol] = _wrap_function(fn, _ffi)<br>
else:<br>
locals[symbol] = fn<br>
<strong>all</strong>.append(symbol)</p>
<p>_import_symbols(locals())</p>
<p>I get this error =</p>
<p>ImportError(“torch.utils.ffi is deprecated. Please use cpp extensions instead.”)</p>

username: Marziye_Mahmoudifar
cooked: <p>how can I solve this error?</p>

username: ptrblck
cooked: <p><a href="https://pytorch.org/tutorials/advanced/cpp_extension.html">This tutorial</a> shows how to use custom CPP extensions.</p>

username: Marziye_Mahmoudifar
cooked: <p>I have a code written in python 2.7, and I want to execute it in python 3.7. I have a error in compiling “setup.py” says this: AttributeError: ‘MSVCCompiler’ object has no attribute ‘compiler_so’<br>
Can you help me with that?</p>

username: ptrblck
cooked: <p>Based on <a href="https://stackoverflow.com/questions/52550831/attributeerror-msvccompiler-object-has-no-attribute-compiler-so">this post</a> it seems as if you are trying to build a Linux lib. Which PyTorch version are you using?</p>

username: Marziye_Mahmoudifar
cooked: <p>The pytorch version is 1.10.1. And I use CUDA version 11.6.0_511.23. I got a file from this github link: <a href="https://github.com/GRAP-UdL-AT/RGBD_fruit_detection_faster-rcnn.pytorch.git" class="inline-onebox" rel="noopener nofollow ugc">GitHub - GRAP-UdL-AT/RGBD_fruit_detection_faster-rcnn.pytorch</a>, and had trouble creating roi_crop, roi_pooling, roi_align and NMS modules.</p>

username: ptrblck
cooked: <p>The repository seems to be quite old now based on the last commits (3 years ago) and these requirements:</p>
<pre><code class="lang-auto">    Python 2.7
    Pytorch 0.2.0
    CUDA 8.0 or higher
</code></pre>
<p>I assume you’ve forked the repo and applied some changes to use the new CPP extensions?</p>

username: Marziye_Mahmoudifar
cooked: <aside class="quote no-group" data-username="mustafa_emre_dos" data-post="1" data-topic="82086">
<div class="title">
<div class="quote-controls"></div>
<img loading="lazy" alt="" width="24" height="24" src="https://discuss.pytorch.org/user_avatar/discuss.pytorch.org/mustafa_emre_dos/48/23843_2.png" class="avatar"> mustafa_emre_dos:</div>
<blockquote>
<p>torch.utils.ffi is deprecated. Please use cpp extensions instead</p>
</blockquote>
</aside>
<p>Yes, I got the following error: (“torch.utils.ffi is deprecated. Please use cpp extensions instead.”) and used CPP extensions according to this link: <a href="https://blog.csdn.net/weixin_44493291/article/details/113097883" rel="noopener nofollow ugc">https://blog.csdn.net/weixin_44493291/article/details/113097883</a></p>

username: ptrblck
cooked: <p>Could you try to use the linked tutorial instead?</p>

username: Marziye_Mahmoudifar
cooked: <p>I studied the linked tutorial but did not come to a conclusion: |</p>

username: Marziye_Mahmoudifar
cooked: <p>Is there a problem with CPP extensions?</p>

username: rishi_dd
cooked: <p>Hey Marziye did you find any workaround for this?</p>