YOLOv5环境配置过程中torch和torchvision版本不匹配

配置yolov5环境时最后一步测试出现错误,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,找了很多方法,卸载安装了很多次。一开始说是torch和torchvision版本不匹配,但看了配置的是和github(GitHub - pytorch/vision: Datasets, Transforms and Models specific to Computer Vision)上一样的,

最后重新卸载安装也不能用,仍然报错。于是就随便试试安装低版本的torch和torchvision,没想到成功解决了。我是将torch1.12.0+torchvision0.13.0换成了torch1.11.0+torchvision0.12.0.

1.先在conda环境中进入自己设置的环境,我的命名为pytorch,激活环境进去后,卸载高版本torch1.12.0和torchvision0.13.0

pip uninstall torch
pip uninstall torchvision

2. 去pytorch官网找之前的版本,https://pytorch.org/

# CUDA 10.2
conda install pytorch==1.11.0 torchvision==0.12.0 torchaudio==0.11.0 cudatoolkit=10.2 -c pytorch

# CUDA 11.3
conda install pytorch==1.11.0 torchvision==0.12.0 torchaudio==0.11.0 cudatoolkit=11.3 -c pytorch

# CPU Only
conda install pytorch==1.11.0 torchvision==0.12.0 torchaudio==0.11.0 cpuonly -c pytorch

根据官网提示选择自己的配置 ,我使用CPU所以使用了最后一行,安装完后再运行测试文件就正常了,咱也不知道这是为啥

 小插曲:中间重新安装torch时,我第一次不知道在哪看的不用加上pytorch官网给的代码的最后一小段 -c pytorch,于是它就出问题了,提示我没有可获得的包,所以大家还是老老实实复制官网上给的代码吧

PackagesNotFoundError: The following packages are not available from current channels:

  - torchvision==0.12.0
  - torchaudio==0.11.0
  - pytorch==1.11.0

 

  • 3
    点赞
  • 18
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Serendipity~~`

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值