对于torch.cuda.available()出现False的解决方法:
- 检查版本是否正确
我的cuda是11.4
pip install torch==1.9.0+cu111 torchvision==0.10.0+cu111 torchaudio==0.9.0 -f https://download.pytorch.org/whl/torch_stable.html
- 检查代码是否正确
device = torch.device("cuda" if torch.cuda.is_available() else "cpu") # 在cpu还是gpu上训练
- 以上都正确,将conda安装改为pip安装
更多推荐
torch.cuda.available()
发布评论