解决RuntimeError: Couldn‘t load custom C++ ops. This can happen if your PyTorch

问题描述

刚下好yolov8的代码,想测一下能否成果,果然没成功,报错如下

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 f
urther 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.

简单来说就是torchvision和torch不匹配,就很离谱,我照着版本对应关系pip install的啊,怎么会不匹配
建议先看看你的版本

python
import torch
import torchvision
print(torch.__version__)
print(torchvision.__version__)

我是下图红框这个
在这里插入图片描述

版本对应博文

首先确定自己torch没问题,因为我的3090这个卡目前cuda版本是11.1,这个whl是早就下好的,一般1-2G,有问题重新下就麻烦了
在这里插入图片描述

在这里插入图片描述
然后我pip install了很多次torchvision==0.11.3,都没啥用。想试着改改版本,结果要下其他的torch版本,就更不可能了。

解决

如果版本对的上,而且后缀都有cu111就没问题了,我的torchvision下了好多次,都没有这个后缀
在这里插入图片描述
方法:去官网https://pytorch.org/get-started/previous-versions/,找到你想要的版本,复制后面的网址
在这里插入图片描述
就是比如这个网址,https://download.pytorch.org/whl/cu111/torchvision/,找到要的whl下载后,本地pip install就好了

在这里插入图片描述

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值