Hi,
Your code sample does have a high memory usage ~5GB but it does not leak memory on my setup. I have a stable memory usage of 4674MB after running 20 iterations.
Removing del loss,loc_output,targets,input and torch.cuda.empty_cache() did not increase the peak memory usage and kept a constant memory usage at the value above.
I’m using pytorch from master (0.4.0a0+4afd62d) with python 2.7 and same cuda/cudnn as you.