在代码中添加以下两行可以解决: torch.backends.cudnn.enabled = True torch.backends.cudnn.benchmark = True 原文:https://www.jianshu.com/p/8486076ddd10