继续运行detect.py,报错
VersionConflict: (torchvision 0.2.2.post3 (d:\yolov5-master\venv\lib\site-packages), Requirement.parse(‘torchvision>=0.8.1’))
也就是torchvision的版本不符合要求
方案一:
参考此链接https://stackoverflow.com/questions/66107660/installing-yolov5-dependencies-torchvision
在pycharm terminal中输入
pip install torch1.7.1+cu101 torchvision0.8.2+cu101 torchaudio==0.7.2 -f https://download.pytorch.org/whl/torch_stable.html
但是报错
ReadTimeoutError(self._pool, None, “Read timed out.”)
pip._vendor.urllib3.exceptions.ReadTimeoutError: HTTPSConnectionPool(host=‘download.pytorch.org’, port=443): Read timed out.
方案二:
其实方案一是在线下载,然后方案二是离线下载
[1] torch版本为1.7.1+cu101 torchvision版本为0.8.2+cu101
a)全部版本下载地址为,https://download.pytorch.org/whl/torch_stable.html
b)torch上述指定版本,https://download.pytorch.org/whl/cu101/torch-1.7.1%2Bcu101-cp39-cp39-win_amd64.whl
c)torchvision上述指定版本,https://download.pytorch.org/whl/cu101/torchvision-0.8.2%2Bcu101-cp39-cp39-win_amd64.whl
[2] 然后pip list
发现原来已经安装的torch就是1.7.1版本的,所以没有再动torch,然后torchvision目前的版本是0.2.2.post3,所以更新刚刚下载好的0.8.2的包。terminal中
pip install XXX.whl 即可
(XXX.whl 是刚刚下载的0.8.2torchvison的离线包 所在的位置/文件名) 没有报错
[3] 我的Torch是1.7.1,但是如果安装torchvison0.8.1就会报错,如下图
所以,查看torch和torchvison对应的版本,戳这里
https://github.com/pytorch/vision#installation
[4] 之后继续运行detect.py发现没有关于torchvison的报错啦,棒(๑•̀ㅂ•́)و✧
[5] 然后没有高兴过三秒,报错还是关于版本不匹配
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.
所以,更新一下刚刚下载的1.7.1的torch看看,OK!
[6] 然后对比,更新torch之前的显示的版本(图1)和更新后(图2)
所以还是有区别的哈,因此,torch和torchvision都要安安稳稳下载离线包然后更新,不能和我一样偷懒哈哈哈哈哈
[7] 继续运行detect.py 妈耶!!!成功了,真是听者落泪,闻者伤心,太感人了!!!!!
参考链接
1)https://stackoverflow.com/questions/66107660/installing-yolov5-dependencies-torchvision
2)https://blog.csdn.net/weixin_45437033/article/details/113557656?utm_medium=distribute.pc_relevant.none-task-blog-baidujs_title-7&spm=1001.2101.3001.4242
3)https://jingyan.baidu.com/article/5552ef47996851518ffbc9d2.html