Cuda out of memory while loading model weights

username: srikarym
cooked: <p>Hello,<br>
I have trained a custom model in pytorch and saved the weights using torch.save(net.state_dict(), path_to_model). When I try to load the model for testing by <code>net.load_state_dict(torch.load(path_to_model)),</code><br>
cuda runtime error (2) : out of memory was raised. The GPU had 12 GB free space while I was trying to load the weights -<br>
<img src="https://discuss.pytorch.org/uploads/default/original/2X/e/e4c97ef52013729010eda301cfa4e0ebf66632ed.PNG" alt="1" data-base62-sha1="wDWz6QmPFdAloROMUmVcG2zV0pT" width="655" height="331"></p>
<p>I specified the gpu device to use by torch.cuda.device(1) and initialized the model by net = my_net(3, 1).cuda(1). I have tried all the permutations (00, 01, 10, 11) of gpu indexes to make sure that it is not an indexing error. I have also noticed that even though I was trying to use GTX Titan, the process was consuming 233 mb in GTX- 1080 TI and displaying this warning -</p>
<p><img src="https://discuss.pytorch.org/uploads/default/original/2X/4/413f9f4f4ee149ef8c74e2dbe45f0ec88422e68d.PNG" alt="2" data-base62-sha1="9jdlr0IBNtgev6ehTo0i3ktqNqZ" width="683" height="129"></p>
<p>I didn’t face any issue while training. Any idea why this is happening?</p>
<p>Thanks in advance!</p>

username: Nicolo_Savioli
cooked: <p>I think:</p>
<p>A. you need to update your CUDA drivers.</p>
<aside class="onebox stackexchange">
  <header class="source">
      <a href="https://askubuntu.com/questions/799184/how-can-i-install-cuda-on-ubuntu-16-04" target="_blank" rel="nofollow noopener">askubuntu.com</a>
  </header>
  <article class="onebox-body">
      <a href="https://askubuntu.com/users/10425/martin-thoma" target="_blank" rel="nofollow noopener">
    <img alt="Martin Thoma" src="https://i.stack.imgur.com/hZKFo.jpg?s=128&amp;g=1" class="thumbnail onebox-avatar" width="60" height="60">
  </a>
<h4>
  <a href="https://askubuntu.com/questions/799184/how-can-i-install-cuda-on-ubuntu-16-04" target="_blank" rel="nofollow noopener">How can I install CUDA on Ubuntu 16.04?</a>
</h4>

<div class="tags">
  <strong>16.04, cuda</strong>
</div>

<div class="date">
  asked by
  
  <a href="https://askubuntu.com/users/10425/martin-thoma" target="_blank" rel="nofollow noopener">
    Martin Thoma
  </a>
  on <a href="https://askubuntu.com/questions/799184/how-can-i-install-cuda-on-ubuntu-16-04" target="_blank" rel="nofollow noopener">03:44AM - 16 Jul 16</a>
</div>

  </article>
  <div class="onebox-metadata">
    
    
  </div>
  <div style="clear: both"></div>
</aside>

<p><a href="https://xcat-docs.readthedocs.io/en/stable/advanced/gpu/nvidia/verify_cuda_install.html" class="onebox" target="_blank" rel="nofollow noopener">https://xcat-docs.readthedocs.io/en/stable/advanced/gpu/nvidia/verify_cuda_install.html</a></p>
<p><a href="https://devtalk.nvidia.com/default/topic/1027653/how-do-i-check-if-i-install-cuda-and-cudnn-successfully-/" class="onebox" target="_blank" rel="nofollow noopener">https://devtalk.nvidia.com/default/topic/1027653/how-do-i-check-if-i-install-cuda-and-cudnn-successfully-/</a></p>
<p>B. then, I suggest you install the pytorch binaries again</p>
<p>conda install pytorch torchvision -c pytorch</p>

username: Vincent_Brisse
cooked: <p>Ever found a solution ? My problem is similar</p>