Solved by Liang in post #9 
              
              
                Problem solved. I migrated from 0.3.0 to 0.4.0, so I add  with torch.no_grad(): myself (in a wrong place). That is like: 
def validate(val_loader, model, criterion):
    batch_time = AverageMeter()
    losses = AverageMeter()
    top1 = AverageMeter()
    top5 = AverageMeter()

    # switch to evalu…