The model won't train on GPU

username: omar_bouhamed
cooked: <p>Hi, am new to pytorch and am trying to run my model on GPU, the Jupyter notebook successfully detect my GPU</p>
<pre><code class="lang-auto">        if torch.cuda.is_available():
            self.device = torch.device("cuda:0")  # you can continue going on here, like cuda:1 cuda:2....etc. 
            print("Running on the GPU")
            torch.cuda.set_device(0)
        else:
            self.device = torch.device("cpu")
            print("Running on the CPU")
</code></pre>
<p>Running on the GPU</p>
<pre><code class="lang-auto">print(torch.cuda.current_device())
print(torch.cuda.get_device_name(torch.cuda.current_device()))
</code></pre>
<p>0<br>
GeForce RTX 2060</p>
<p>and I used .to(device) for the model and its inputs</p>
<pre><code class="lang-auto">self.dqn = Network(states_dim, action_dim).to(self.device)
</code></pre>
<p>But it is still working on CPU<br>
<div class="lightbox-wrapper"><a class="lightbox" href="https://discuss.pytorch.org/uploads/default/original/3X/c/6/c6ba957d62c1166eb1280cf36f7842d6d0c41d0a.png" data-download-href="https://discuss.pytorch.org/uploads/default/c6ba957d62c1166eb1280cf36f7842d6d0c41d0a" title="image"><img src="https://discuss.pytorch.org/uploads/default/original/3X/c/6/c6ba957d62c1166eb1280cf36f7842d6d0c41d0a.png" alt="image" data-base62-sha1="sm2ibQWqTyAbBi3EfEh7EjlN9VM" width="293" height="500" data-dominant-color="F2F3F5"><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">349×595 13.6 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>Thank you for your help.</p>

username: ptrblck
cooked: <p>The Windows task manager is often nor properly reporting the GPU utilization so you could either select the “compute” output in a drop down menu (I’m no Windows expert as you might notice <img src="https://discuss.pytorch.org/images/emoji/apple/wink.png?v=9" title=":wink:" class="emoji" alt=":wink:"> ) or use <code>nvidia-smi</code>.</p>

username: omar_bouhamed
cooked: <p>Yes, it looks like the task manager isn’t showing the real state of the GPU use. Thank you!<br>
The python.exe is running on GPU but it seems that the GPU is not working at full capacity. is there something wrong or it depends on my model…?<br>
<div class="lightbox-wrapper"><a class="lightbox" href="https://discuss.pytorch.org/uploads/default/original/3X/8/a/8a2fdb5bb25b902abdf65882cd9d0446dabe67b3.png" data-download-href="https://discuss.pytorch.org/uploads/default/8a2fdb5bb25b902abdf65882cd9d0446dabe67b3" title="image"><img src="https://discuss.pytorch.org/uploads/default/original/3X/8/a/8a2fdb5bb25b902abdf65882cd9d0446dabe67b3.png" alt="image" data-base62-sha1="jIsqh2HfOUKwjtMThgLub6tTZ2H" width="690" height="341" data-dominant-color="0C0C0C"><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">726×359 9.8 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>

username: ptrblck
cooked: <p>It depends on the model and overall training script. E.g. your data loading might create bottlenecks or the model workload might be too small to properly saturate the GPU.</p>