akankshakshurai/cuda-error-resolution-analysis huggingface dataset:
Double backward in torch2.0?

Q-Y_Zhuang: <p>I just tried torch2.0, which was for sure amazing. However, on my research purpose, I would like to do double backward in my code, which is not currently supported by torch2.0. Would you have a rough estimate that how soon it will be supported?</p>

KFrank: <p>Hi Qinyu!</p>
<aside class="quote no-group" data-username="Q-Y_Zhuang" data-post="1" data-topic="175454" data-full="true">
<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/q-y_zhuang/48/58613_2.png" class="avatar"> Q-Y_Zhuang:</div>
<blockquote>
<p>I would like to do double backward in my code, which is not currently supported by torch2.0.</p>
</blockquote>
</aside>
<p>I’m not sure what you mean by “double backward.”  If you want to compute,<br>
for example, second derivatives (e.g., a hessian), pytorch version 2.0.0<br>
works for me:</p>
<pre><code class="lang-plaintext">&gt;&gt;&gt; torch.__version__
'2.0.0'
&gt;&gt;&gt; t = torch.ones (1, requires_grad = True)
&gt;&gt;&gt; p = t**3
&gt;&gt;&gt; d1 = torch.autograd.grad (p, t, create_graph = True)
&gt;&gt;&gt; d2 = torch.autograd.grad (d1, t)
&gt;&gt;&gt; d1
(tensor([3.], grad_fn=&lt;MulBackward0&gt;),)
&gt;&gt;&gt; d2
(tensor([6.]),)
</code></pre>
<p>If you have a different use case in mind, please post a fully-self-contained,<br>
runnable script that shows what you are trying to do and how it fails,<br>
together with its output.</p>
<p>Best.</p>
<p>K. Frank</p>

soulitzer: <p>The issue is tracked <a href="https://github.com/pytorch/pytorch/issues/91469" class="inline-onebox" rel="noopener nofollow ugc">torch.compile with aotautograd does not support double backwards · Issue #91469 · pytorch/pytorch · GitHub</a> if you are wondering about torch.compile support.</p>

Q-Y_Zhuang: <p>Hi Frank, thank you a lot for trying. Sorry I didn’t make it clear with my question. The torch.compile in Pytorch 2.0 doesn’t support double backward. Without torch.compile, everything seems fine.</p>

Q-Y_Zhuang: <p>Thank you soulitzer, yes, that was my concern.</p>
No module named ‘torchvision’ despite being installed

imsosad: <p>Hi there<br>
I installed torch vision by ‘conda install -c pytorch torchvision’<br>
but I am getting an import error when importing it into my code.</p>
<p>The code is</p>
<p>import torchvision</p>
<p>I check sys.path but there no problem.<br>
But I can import torchvision on my terminal after warning that “UserWarning: Failed to load image Python extension”<br>
Then the version is 0.13.1a0</p>
<p>Please help me</p>

ptrblck: <aside class="quote no-group" data-username="imsosad" data-post="1" data-topic="175472">
<div class="title">
<div class="quote-controls"></div>
<img loading="lazy" alt="" width="24" height="24" src="https://discuss.pytorch.org/letter_avatar_proxy/v4/letter/i/4bbf92/48.png" class="avatar"> imsosad:</div>
<blockquote>
<p>But I can import torchvision on my terminal</p>
</blockquote>
</aside>
<p>This could mean that the Python environment used in your terminal is different from the one used before.</p>
<aside class="quote no-group" data-username="imsosad" data-post="1" data-topic="175472">
<div class="title">
<div class="quote-controls"></div>
<img loading="lazy" alt="" width="24" height="24" src="https://discuss.pytorch.org/letter_avatar_proxy/v4/letter/i/4bbf92/48.png" class="avatar"> imsosad:</div>
<blockquote>
<p>but I am getting an import error when importing it into my code.</p>
</blockquote>
</aside>
<p>What kind of import error are you seeing?</p>

imsosad: <p>I getted the no module named ‘torchvision’ error.</p>
<p>Before getting this error, torch and matplotlib were not imported at the same time, even though each was imported. So I reinstalled torch, but torchvision is not imported.</p>
<p>I also reinstalled torchvision, and at first it imported fine in the terminal. But after reinstalling, the Userwarning pops up😂</p>

ptrblck: <aside class="quote no-group" data-username="imsosad" data-post="3" data-topic="175472">
<div class="title">
<div class="quote-controls"></div>
<img loading="lazy" alt="" width="24" height="24" src="https://discuss.pytorch.org/letter_avatar_proxy/v4/letter/i/4bbf92/48.png" class="avatar"> imsosad:</div>
<blockquote>
<p>I also reinstalled torchvision, and at first it imported fine in the terminal. But after reinstalling, the Userwarning pops up😂</p>
</blockquote>
</aside>
<p>You can ignore the <code>UserWarning</code> as it would only indicate the <code>torchvision.io</code> backend wasn’t built in the pip wheel / conda binary, which might be expected.</p>

imsosad: <p>Thank you.</p>
<p>So what do I need to do to import torchvision not in terminal but inside code?</p>

imsosad: <p>Hi</p>
<p>I solved the problem after reinstalling condo again. Thank you <img src="https://discuss.pytorch.org/images/emoji/apple/slight_smile.png?v=12" title=":slight_smile:" class="emoji" alt=":slight_smile:" loading="lazy" width="20" height="20"></p>