Try setting requires_grad=False to all Variable 's that do not require gradient computation (i.e. input images and labels). For instance, replace
images = Variable(images.cuda())
by
images = Variable(images.cuda(), requires_grad=False)
During inference (i.e. when you do not want to backpropagate gradients), you should also set volatile=True.
These things will help reducing memory consumption a bit. For more info. on this, check http://pytorch.org/docs/notes/autograd.html 80.