Hi, I solved the problem by installing pytorch 0.3.1
Here is my code:
“#My pretrained model” is ResNet101 + 1 Conv2d.  It was trained on my old computer with pytorch 0.3.1.
net.load_state_dict(torch.load("#My pretrained model"))
net.cuda()
val_set = Voc2012Segmentation('val', transform=None,
                              target_transform=None)
test_loader = torch.utils.data.DataLoader(val_set, batch_size=4,
                                           shuffle=False, num_workers=0)

dataiter = iter(test_loader)
net.eval()
for img_num in range(20):

    image, target = dataiter.next()
    image = Variable(image.cuda())
    target = Variable(target.cuda())
    heatmap = net(image)