admin管理员组文章数量:1608626
在使用torchvision的op的时候,比如from torchvision.ops.nms
如果遇到以下的问题:
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/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中在这里打印出来:
def _assert_has_ops():
if not _has_ops():
raise 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/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."
)
原因就是pytorch版本和torchvision没有匹配,必须要完全匹配。
通过pip list
命令查看的时候是这样的才行:
torch 1.8.1+cu111
torchvision 0.9.1+cu111
比如1.8.1对应0.9.1,而1.8.0对应0.9.1,这个匹配关系可以看官方的。而且后面的cu111必须也一致!
不一致的话,直接输入网址安装就行:
pip install https://download.pytorch/whl/cu111/torchvision-0.9.1%2Bcu111-cp38-cp38-linux_x86_64.whl
官方的地址:
https://download.pytorch/whl/
本文标签: TorchVisionop
版权声明:本文标题:遇到torchvision-op无法调用的问题 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:https://www.elefans.com/xitong/1728550948a1163426.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论