Getting network training with CUDA

username: krioux5
cooked: <p>Hello,</p>
<p>I have defined a U-net as well as training code, however I don’t think it is training with CUDA (using GPU’s). In my limited experience with tf, I know that as I began training with CUDA, it would output a message stating that CUDA is running, devices were identified etc. Is there something similar for pytorch? I am just going based on the fact that GPU utilization is very low.<br>
<img src="https://discuss.pytorch.org/uploads/default/original/3X/6/a/6a3bbfadb8fef2741c30b62624d93fa0fe1226da.png" alt="image" data-base62-sha1="f9MCCFnTNyqKfEWjt1PhzFBEZnA" width="281" height="464"><br>
I have included a few lines in my code that I thought would encourage CUDA use, but I don’t beieve it’s worked ie.</p>
<pre><code class="lang-auto">self.device = torch.device("cuda:0")
torch.set_default_tensor_type("torch.cuda.FloatTensor")
</code></pre>
<p>Is there anything else for me to keep in mind? I briefly reviewed <a href="https://pytorch.org/docs/stable/notes/cuda.html#:~:text=cuda%20is%20used%20to%20set,cuda" class="inline-onebox" rel="noopener nofollow ugc">CUDA semantics — PyTorch 2.1 documentation</a>. but I am a bit ‘lost in the documentation’</p>
<p>Thanks,</p>
<p>kyle</p>

username: ebarsoum
cooked: <p>Do you have NVidia GPU? The above screenshot shows only Intel integrated GPU.</p>

username: krioux5
cooked: <p>Sorry, my bad<br>
<div class="lightbox-wrapper"><a class="lightbox" href="https://discuss.pytorch.org/uploads/default/original/3X/0/2/0236a844dbc87b77fba9545b972d64f5fd3946da.png" data-download-href="https://discuss.pytorch.org/uploads/default/0236a844dbc87b77fba9545b972d64f5fd3946da" title="image"><img src="https://discuss.pytorch.org/uploads/default/original/3X/0/2/0236a844dbc87b77fba9545b972d64f5fd3946da.png" alt="image" data-base62-sha1="jA3zFNpbK9h8vDDeWkyeSgQQJ4" width="244" height="500" data-dominant-color="F0F0F0"><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">302×618 16 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><br>
This screenshot shows the Nvidia GPU. I have made CUDA work in tensorflow before, so I know my CUDA is setup correctly- I assume the issue is related to my code and the way I’m calling it.</p>
<p>Kyle</p>

username: albanD
cooked: <p>Hi,</p>
<p>I think there are know issue with the windows task manager that does not report cuda use of the GPU. And so it is expected to remain close to 0% usage in there.<br>
You can use cli tools like nvidia-smi to see what happens.<br>
Or temps? 71C doesn’t look like an idle card <img src="https://discuss.pytorch.org/images/emoji/apple/smiley.png?v=9" title=":smiley:" class="emoji" alt=":smiley:"></p>

username: krioux5
cooked: <p>Training is also extremely slow, leading me to believe cuda actually isn’t working</p>

username: harris
cooked: <p>Hey, I don’t know how the overall utilization of GPU is calculated by windows but you can see the CUDA utilization in the graph area.<div class="lightbox-wrapper"><a class="lightbox" href="https://discuss.pytorch.org/uploads/default/original/3X/d/d/dd5258867eebd08c77bc18360d434bc431b77b54.jpeg" data-download-href="https://discuss.pytorch.org/uploads/default/dd5258867eebd08c77bc18360d434bc431b77b54" title="image"><img src="https://discuss.pytorch.org/uploads/default/optimized/3X/d/d/dd5258867eebd08c77bc18360d434bc431b77b54_2_666x500.jpeg" alt="image" data-base62-sha1="vzTWEz4Q79U1V6tkEROQqUcQL40" width="666" height="500" srcset="https://discuss.pytorch.org/uploads/default/optimized/3X/d/d/dd5258867eebd08c77bc18360d434bc431b77b54_2_666x500.jpeg, https://discuss.pytorch.org/uploads/default/optimized/3X/d/d/dd5258867eebd08c77bc18360d434bc431b77b54_2_999x750.jpeg 1.5x, https://discuss.pytorch.org/uploads/default/optimized/3X/d/d/dd5258867eebd08c77bc18360d434bc431b77b54_2_1332x1000.jpeg 2x" data-dominant-color="97968C"><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">2016×1512 1.66 MB</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>

username: ebarsoum
cooked: <p>Can you run nvidia-smi?</p>

username: krioux5
cooked: <p>I switched to my linux machine and am able to tell now with this!</p>