I was trying to implement Deep Dream in pytorch and that’s why i was passing “out” to the out.backward() so that i can get gradient of my input image with respect to output.
I found that if you pass a Variable object to backward() then my RAM memory consumption is increasing by each iteration (don’t know why) . Therefore now I’m passing out.data which is torch.Tensor type and It’s working properly  .