【python】yolov5的torch与torchvision环境问题

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

wait a minute~

我还没有学会写个人说明!

暂无评论

发表评论

相关推荐

pytorch建立mobilenetV3-ssd网络并进行训练与预测

前言 这篇文章记录的是我在公司实习用深度学习做车辆信息识别项目时,用来做车辆检测的算法。因为我们公司面向的边缘端计算,边缘盒子的计算能力有限,所以我们在做算法研究时,就尽量选用轻量级算法

MMdetection环境搭建(win10)

一、 创建虚拟环境 这里创建python3.7环境 二、安装torch及cudatoolkit 进入torch官网,找到需要的torch及cuda(torch官网已经搭配并打包一起,后续不用设置环境变