akankshakshurai/cuda-error-resolution-analysis huggingface dataset:
Image Mode not Accepted w/ Integrated Gradients

anmolseth00: <p>I’m working with the integrated gradients notebook sourced from here:(<a href="https://pytorch.org/tutorials/beginner/introyt/captumyt.html" class="inline-onebox" rel="noopener nofollow ugc">Model Understanding with Captum — PyTorch Tutorials 2.2.0+cu121 documentation</a>)</p>
<ul>
<li>“Download the notebook and corresponding files <a href="https://pytorch-tutorial-assets.s3.amazonaws.com/youtube-series/video7.zip" rel="noopener nofollow ugc">here</a>.”</li>
</ul>
<p>I’m unable to run this line <code>img = resize(test_img)</code>. I’ve attached a screenshot of the error message below</p>
<p><div class="lightbox-wrapper"><a class="lightbox" href="https://discuss.pytorch.org/uploads/default/original/3X/b/1/b101861c435c64079cd6167f0f35ebcd20ce9c59.png" data-download-href="https://discuss.pytorch.org/uploads/default/b101861c435c64079cd6167f0f35ebcd20ce9c59" title="image"><img src="https://discuss.pytorch.org/uploads/default/optimized/3X/b/1/b101861c435c64079cd6167f0f35ebcd20ce9c59_2_690x488.png" alt="image" data-base62-sha1="pfRMbkZItgpcfNY1Nk2XiZbSyLf" width="690" height="488" srcset="https://discuss.pytorch.org/uploads/default/optimized/3X/b/1/b101861c435c64079cd6167f0f35ebcd20ce9c59_2_690x488.png, https://discuss.pytorch.org/uploads/default/original/3X/b/1/b101861c435c64079cd6167f0f35ebcd20ce9c59.png 1.5x, https://discuss.pytorch.org/uploads/default/original/3X/b/1/b101861c435c64079cd6167f0f35ebcd20ce9c59.png 2x" data-dominant-color="F9FAF6"><div class="meta"><svg class="fa d-icon d-icon-far-image svg-icon" aria-hidden="true"><use href="#far-image"></use></svg><span class="filename">image</span><span class="informations">939×665 89.9 KB</span><svg class="fa d-icon d-icon-discourse-expand svg-icon" aria-hidden="true"><use href="#discourse-expand"></use></svg></div></a></div></p>
<p>The file I’m using is a .tif file in the ‘I;16’ format which isn’t being accepted. My questions are</p>
<ol>
<li>What are the accepted image formats for this notebook?</li>
<li>Does anyone have any experience converting I;16 format files into a different image format that would be accepted?</li>
</ol>
<p>Thank you in advance!</p>

harpone: <p>Your image is probably not an image…</p>

anmolseth00: <p>Hi <a class="mention" href="/u/harpone">@harpone</a> , thanks for your response! I believe the .tif file is a type of image (specifically, a 16-bit unsigned integer image based on what I’m seeing online)</p>

harpone: <p>OK I think it could be a good idea to go to line 3 with a debugger and compare to loading a regular jpeg… if you’re using PIL to open the image, then maybe also use <code>.convert("RGB")</code> to make sure it’s RGB etc. But not really sure, haven’t worked with TIFFs a lot.</p>
Question about cuda graph

jake_y: <p>I have a question on CUDA graph.</p>
<p>This is the typical usage of CUDA graph:</p>
<pre><code class="lang-auto">with torch.cuda.graph(g):
    static_y_pred = model(static_input)
    static_loss = loss_fn(static_y_pred, static_target)
    static_loss.backward()
    optimizer.step()
</code></pre>
<p>My question is, when I build the model, if there are some cpu operations,<br>
for example:</p>
<pre><code class="lang-auto">x = layer_0(x)
x = layer_1(x)
x = layer_2(x)
x = layer_3(x)
</code></pre>
<p>suppose I specifically want to run layer_1() or layer_2() on CPU (I can also say that I want to transfer the data between CPU and GPU and process the tensor).</p>
<p>Is cuda_graph able to captures these behavior? I guess there is a need to record the dependency before the capture and after the capture? If there is single one compute stream. It would be easy to do so?</p>
<p>Thanks.</p>

jake_y: <p>gentle ping <a class="mention" href="/u/mcarilli">@mcarilli</a></p>
Colab Session Crashes on importing torch_geometric.nn

Fawad: <p>Colab crashes while executing the following line</p>
<pre><code class="lang-auto">from torch_geometric.nn import MessagePassing
</code></pre>
<p>I have made these installations</p>
<pre><code class="lang-auto">!pip install -q torch-scatter -f https://data.pyg.org/whl/torch-1.10.0+cu113.html

!pip install -q torch-sparse -f https://data.pyg.org/whl/torch-1.10.0+cu113.html

!pip install -q git+https://github.com/pyg-team/pytorch_geometric.git
</code></pre>
Weights saved in TorchScript?

YoPit: <p>Hello,</p>
<p>Sorry if my question is too simple or naive but I’m new in jit/TorchScript.</p>
<p>I have saved a model with <code>torch.jit.script</code> <strong>after</strong> the training loop and want to load it in C++ for inference using the <code>torchlib</code>.  Is it enough to save the model in this way to keep the trained weights or should I do something more?<br>
Thanks!</p>

ptrblck: <p>It should be enough to export the model via <code>torch.jit.save</code> as described in <a href="https://pytorch.org/tutorials/advanced/cpp_export.html">this tutorial</a>.</p>

YoPit: <p>Thanks for your reply</p>
Train vs Eval Mode for Auxiliary Loss Model

Joseph_Konan: <p>I have two models, one primary and one auxiliary. I want to fix the weights of the auxiliary network. However, I am unsure if I should put the auxiliary network in train mode or eval mode.</p>
<p>For example…</p>
<p>Signal_2_pred = PrimaryModel(Signal_1)<br>
loss = MSE(Signal_2_pred, Signal_2_true)<br>
loss += MSE(AuxiliaryModel(Signal_2_pred), Signal_2_aux)</p>
<p>I do not want to change the weights of the AuxiliaryModel, but I do want the gradients to be propagated. Does this require train mode or eval mode for the auxiliary?</p>

ptrblck: <aside class="quote no-group" data-username="Joseph_Konan" data-post="1" data-topic="154235">
<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/joseph_konan/48/25213_2.png" class="avatar"> Joseph_Konan:</div>
<blockquote>
<p>Does this require train mode or eval mode for the auxiliary?</p>
</blockquote>
</aside>
<p>The <code>train()</code> and <code>eval()</code> modes are orthogonal to the gradient computation as they are changing the behavior of some modules. E.g. batchnorm layers will use the running stats to normalize the input activation during eval and dropout will be disabled.<br>
The gradient calculation can be disabled either via setting the <code>.requires_grad</code> attribute of parameters to <code>False</code> or e.g. by using <code>with torch.no_grad()</code>.</p>
I want to convert multiple images converted to NumPy to tensor

YuhskeHujisaki: <p>Is there a library that converts NumPy images with sizes (3158, 224, 224, 3) to tensors of size (3158, 3,224, 224) at once?<br>
How can I convert a size (3158, 224, 224, 3) to a tensor of size (3158, 3,224, 224) at once in a numpy format image?</p>

ptrblck: <p>You won’t be able to use a single operation, but could use <code>torch.from_numpy</code> and either <code>permute</code> the tensor or <code>transpose</code> the numpy array.</p>