akankshakshurai/cuda-error-resolution-analysis huggingface dataset:
How can convert 1 channel tensor to PIL Image?

username: jungminchung
cooked: <p>Hello all, I am new to pytorch.<br>
I made a model that returns shape (1, 128, 128) tensor and wanted to resize it to (1, 101, 101). To use transforms.Resize(), I converted the tensor to PIL image using transforms.ToPILImage(mode=‘L’) function. Then, the system said ‘ValueError: Only modes [‘RGB’, ‘YCbCr’, ‘HSV’] are supported for 3D inputs’ !!<br>
But, I think my tensor has 1 channel not 3D inputs.<br>
my question is</p>
<ul>
<li>how to convert 1 channel tensor to PIL Image ?</li>
<li>is there better way to resize tensor than i did ??</li>
</ul>
<p>Thanks in advance! <img src="https://discuss.pytorch.org/images/emoji/apple/smile.png?v=6" title=":smile:" class="emoji" alt=":smile:"></p>

username: ptrblck
cooked: <p>That’s strange, as this code seems to work:</p>
<pre><code class="lang-python">image = transforms.ToPILImage(mode='L')(torch.randn(1, 96, 96))
</code></pre>
<p>However, you could just simply slice your image and pass it to your transformation:</p>
<pre><code class="lang-python">transform(image[0])
</code></pre>

username: jungminchung
cooked: <p>Thanks for reply!<br>
I found some errors in my code - I put numpy type data as input format,<br>
and it works well now <img src="https://discuss.pytorch.org/images/emoji/apple/sweat_smile.png?v=6" title=":sweat_smile:" class="emoji" alt=":sweat_smile:"></p>

username: Melika-Ayoughi
cooked: <p>I have kind of the same problem but I’m trying to call to_pil_image on a tensor that consists of sequences of grayscale images. [seq_len, width, height]. How can I call this function on all images? Because now it thinks that my image has 10 (10-seq_len) channels.</p>
"Automatic parallelization of models onto multiple GPUs"

username: dambo
cooked: <p>Hello,<br>
I have a traced model which i use in C++.<br>
The documentation clearly states: “Automatic parallelization of models onto multiple GPUs like torch.nn.parallel.DataParallel”.</p>
<p>However I do not see this happening on a multi-gpu device. How do i explicitly force the <code>auto module = torch::jit::load(s_model_name, torch::kCUDA);</code> module to be defined like it would be in pure PyTorch?</p>
<p>Thanks.</p>

username: dambo
cooked: <p>Anyone knows the answer to this?</p>