前言

1、AssertionError: Torch not compiled with CUDA enabled

在这里插入图片描述
此错误是由于下载的torch没有cuda,在运行时就会出错;

2、解决方式

在程序最开始的地方加上

device = torch.device("cuda" if torch.cuda.is_available() else "cpu")

举例如下:
在这里插入图片描述
代码其余地方出现.cuda()的地方改成.to(device)就可以在无gpu的环境中运行了


总结

分享:
Don"t makepromisesyou can"t keep.But those are the bestkind.不轻许做不到的承诺,但做不到的承诺往往最美好。

Logo

为开发者提供学习成长、分享交流、生态实践、资源工具等服务,帮助开发者快速成长。

更多推荐