#解决python3.7与torch版本不匹配问题
##问题:RuntimeError: The NVIDIA driver on your system is too old (found version 10010). Please update your GPU driver by downloading and installing a new version from the URL: http://www.nvidia.com/Download/index.aspx Alternatively, go to: https://pytorch.org to install a PyTorch version that has been compiled with your version of the CUDA driver.
##解决:
pip install torch1.7.1+cu101 torchvision0.8.2+cu101 torchaudio==0.7.2 -f https://download.pytorch.org/whl/torch_stable.html
问题:RuntimeError: No CUDA GPUs are available
解决方法:
// 检测一下cuda是否可用 print(torch.cuda.is_available()) False //重新在文件头加入下面说明 import torch torch.cuda.current_device() torch.cuda._initialized = True
参考博客
解决方法:
1、首先在报错的位置net.cuda前加入cuda检测语句:
print(torch.cuda.is_available())
1
输出为False,证明cuda不可用
2、检查本机中的cuda是否安装成功,且版本号是否与pytorch的版本号对应。检查发现没有问题
3、检查os.environ[“CUDA_VISIBLE_DEVICES”] = "1"语句,将1改为0,再运行无误。原因可能是本机上只有一个cuda,序号应为0。
参考博客



