title: Why do I get CUDA out of memory when running PyTorch model [with enough GPU memory]?
body: <p>I am asking this question because I am successfully training a segmentation network on my GTX 2070 on laptop with 8GB VRAM and I use <strong>exactly the same code and exactly the same software libraries installed</strong> on my desktop PC with a GTX 1080TI and it still throws out of memory.</p>
  <p>Why does this happen, considering that:</p>
  <ol>
  <li><p>The same Windows 10 + CUDA 10.1 + CUDNN 7.6.5.32 + Nvidia Driver 418.96 (comes along with CUDA 10.1) are both on laptop and on PC.</p>
  </li>
  <li><p>The fact that training with TensorFlow 2.3 runs smoothly on the GPU on my PC, yet it fails allocating memory for training only with PyTorch.</p>
  </li>
  <li><p>PyTorch recognises the GPU (prints GTX 1080 TI) via the command : <code>print(torch.cuda.get_device_name(0))</code></p>
  </li>
  <li><p>PyTorch allocates memory when running this command: <code>torch.rand(20000, 20000).cuda()</code> <code>#allocated 1.5GB of VRAM.</code></p>
  </li>
  </ol>
  <p>What is the solution to this?</p>