Thanks, that works partially. Here I found that if I comment these lines:
                   if eval_flip:
                        out = net(torch.flip(im, dims=(3,)))
                        out = torch.flip(out, dims=(3,))
                        out = F.interpolate(out, (H, W), mode='bilinear',
                                align_corners=True)
                        prob = F.softmax(out, 1)
                        probs += prob.cpu()

The memory would reduce around 3G. Why the memory usage is reduced, and do I have a chance to take use of it here?