torch.cuda.empty_cache doesn’t give PyTorch extra GPU memory to use.  See http://pytorch.org/docs/master/notes/cuda.html#memory-management 713. So it won’t help if you are solving a OOM with only PyTorch using that GPU.
The structure of your code segment looks fine. So it’s probably one of  loss_function, init_hidden, tester.test, or tester.print_samples that’s causing the issue.