AssertionError: Torch not compiled with CUDA enabled 原来代码中 device = torch.device('cuda') 此错误是由于下载的torch没有cuda,在运行时就会出错,经过查阅,应该改为 device = torch.device("cuda" if torch.cuda.is_available() else "cpu")