RuntimeError: No such operator torchvision::nms解决方案
跑代码的时候碰到了"RuntimeError: No such operator torchvision::nms"
,找到的资料显示大多是"torch"
和"torchvision"
版本不匹配,让二者版本一致即可解决。但我查看环境中的torch和torchvision的版本后,发现二者是匹配的。
报错可能是因为两个包安装的方式不同。后来,通过在官网下载whl安装"torch"
和"torchvision"
,解决了该问题:
![](https://i-blog.csdnimg.cn/direct/ed473c5fe85148a6a48325a526514338.png)
![](https://i-blog.csdnimg.cn/direct/756e734ab8724adeb5e0f412e16d46b6.png)
这里我下载了上图中的"torch"
和"torchvision"
版本,之后命令行安装:
python -m pip install torch-2.3.0+cu118-cp39-cp39-linux_x86_64.whl
python -m pip install torchvision-0.18.0+cu118-cp39-cp39-linux_x86_64.whl
再次运行代码,没有报错,可以正常运行了。