文章目录[隐藏]
1.可用环境
torch==1.7.1+cu110
torchvision==0.8.2+cu110
2.错误环境遇到的问题
(1)情况一
torch==1.7.0+cu110
torchvision==0.8.0
训练yolov5时,训练就会开始报错:
return torch.ops.torchvision.nms(boxes, scores, iou_threshold)
RuntimeError: Could not run 'torchvision::nms' with arguments from the 'CUDA' backend. 'torchvision::nms' is only available for these backends: [CPU, BackendSelect, Named, AutogradOther, AutogradCPU, AutogradCUDA, AutogradXLA, Tracer, Autocast, Batched, VmapMode].
torchvision版本不对。 所以升级了torchvision的版本。进入到情况二。
(2)情况二
torch==1.7.0+cu110
torchvision==0.8.1
训练第一个epoch时,不出错,但是测试第一个epoch的时候,会报错:
"Couldn't load custom C++ ops. This can happen if your PyTorch and "
RuntimeError: Couldn't load custom C++ ops. This can happen if your PyTorch and torchvision versions are incompatible, or if you had errors while compiling torchvision from source. For further information on the compatible versions, check https://github.com/pytorch/vision#installation for the compatibility matrix. Please check your PyTorch version with torch.__version__ and your torchvision version with torchvision.__version__ and verify if they are compatible, and if not please reinstall torchvision so that it matches your PyTorch install.
torch版本不对。这个时候就要torch与torchvision对应的一起升级。
3.针对以上分析
找到了正确的环境:
torch==1.7.1+cu110
torchvision==0.8.2+cu110
安装:
pip install torch==1.7.1+cu110 -f https://download.pytorch.org/whl/torch_stable.html
pip install torchvision==0.8.2+cu110 -f https://download.pytorch.org/whl/torch_stable.html
版权声明:本文为CSDN博主「wait a minute~」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/qq_35975447/article/details/116852693
暂无评论