数据集的路径不存在,你检查一下,你的数据放在哪个地方
复制官网的安装命令(继续在上面的命令行终端中运行conda xxxx -c pytorch)
如果换源了,需要删除掉安装命令中的’-c pytorch’,否则还是使用的官方源
这个报错是因为您的程序在调用PyTorch的函数时,出现了CUDA运行错误。可能是因为您没有正确安装或配置CUDA或PyTorch的CUDA版本不匹配等原因引起的。
解决思路如下:
1.检查CUDA是否正确安装,并且版本是否和PyTorch匹配。
2.检查PyTorch是否正确安装,并且版本是否和CUDA匹配。
3.如果您的计算机没有安装CUDA,可以考虑使用CPU版本的PyTorch。
4.如果以上方法都无法解决问题,可以尝试重新安装PyTorch和CUDA,并确保版本匹配。
示例代码:
import torch
# 检查CUDA是否可用
if torch.cuda.is_available():
print('CUDA is available')
else:
print('CUDA is not available')
# 检查PyTorch版本和CUDA版本
print(torch.__version__)
print(torch.version.cuda)
# 检查GPU是否可用
device = torch.device('cuda' if torch.cuda.is_available() else 'cpu')
print(device)
# 重新安装PyTorch和CUDA
# pip uninstall torch
# pip uninstall torchvision
# 卸载CUDA
# 重新安装CUDA
# 安装PyTorch和torchvision
# pip install torch torchvision -f https://download.pytorch.org/whl/cu101/torch_stable.html