title: Getting CUDA out of memory
body: <p>Im trying to train a network but i get,
  I set my batch-size as 300 and i get this error,but even if i reduce this to 100 i still get this error,and more frustratingly for running 10 epoch on ~1200 images it takes about 40 minutes,any suggestions what is going wrong and how may i speed the process!
  Any tips will be extremely helpful,Thanks in advance. </p>
  
  <pre><code>---------------------------------------------------------------------------
  RuntimeError                              Traceback (most recent call last)
  &lt;ipython-input-31-3b43ff4eea72&gt; in &lt;module&gt;()
        5         labels = Variable(labels).cuda()
        6 
  ----&gt; 7         optimizer.zero_grad()
        8         outputs = cnn(images)
        9         loss = criterion(outputs, labels)
  
  /usr/local/lib/python3.5/dist-packages/torch/optim/optimizer.py in     zero_grad(self)
      114                 if p.grad is not None:
      115                     if p.grad.volatile:
  --&gt; 116                         p.grad.data.zero_()
      117                     else:
      118                         data = p.grad.data
  
  RuntimeError: cuda runtime error (2) : out of memory at /pytorch  /torch/lib/THC/generic/THCTensorMath.cu:35`
  </code></pre>
  
  <p>Even though my GPU's are free</p>
  
  <pre><code>+-----------------------------------------------------------------------------+
  | NVIDIA-SMI 384.111                Driver Version: 384.111                       |
  |-------------------------------+----------------------+----------------------+
  | GPU  Name        Persistence-M| Bus-Id        Disp.A | Volatile Uncorr. ECC |
  | Fan  Temp  Perf  Pwr:Usage/Cap|         Memory-Usage | GPU-Util  Compute M. |
  |===============================+======================+======================|
  |   0  GeForce GTX 108...  Off  | 00000000:05:00.0 Off |                   N/A |
  | 23%   18C    P8    15W / 250W |  10864MiB / 11172MiB |      0%      Default |
      +-------------------------------+----------------------+----------------------+
  
  |   1  GeForce GTX 108...  Off  | 00000000:08:00.0 Off |                  N/A |    
   | 23%   20C    P8    15W / 250W |     10MiB / 11172MiB |          0%      Default
  +-------------------------------+----------------------+---------------
  </code></pre>