Vision: No such operator torchvision::nms

Created on 2 Oct 2019  路  36Comments  路  Source: pytorch/vision

Hi,

I'm get an error when I try to use new torch.ops, e.g.

import torch
torch.ops.torchvision.nms

results in

/usr/local/lib/python3.6/dist-packages/torch/_ops.py in __getattr__(self, op_name)
---> 61         op = torch._C._jit_get_operation(qualified_op_name)

RuntimeError: No such operator torchvision::nms`

No matter if I use nightly build or master clone, e.g.
pip install --pre torch torchvision -f https://download.pytorch.org/whl/nightly/cu100/torch_nightly.html

How to debug setup.py to track where comilation/loading fails?

binaries

Most helpful comment

@chiboreache PyTorch 1.6.0 requires torchvision 0.7.0

All 36 comments

Hi,

There is currently a problem with the torchvision wheels for the nightlies, they haven't been updated in more than 10 days.

The error you are getting indicates that you haven't compiled the new torchvision extensions.
For that, you should clone the repo, uninstall torchvision, remove any potential pre-built version (via python setup.py clean), and then re-install it with python setup.py install.

This should work I believe.

cc @soumith for the problem pushing nightlies for torchvision

@fmassa, unfortunatelly it still doesn't work even on clean simple install path

mkvirtualenv pt1
pip install --pre torch -f https://download.pytorch.org/whl/nightly/cu100/torch_nightly.html
pip install numpy six
git clone https://github.com/pytorch/vision.git
cd vision
python setup.py install

I don't see any signs of errors during compilation process

Ok, I see a problem in
https://github.com/pytorch/vision/blob/bf8595798eaccbaffb6c04db11406426eb1b3800/torchvision/ops/boxes.py#L31
Should there be return torchvision.ops.nms(boxes, scores, iou_threshold)?

Sorry, I messed up sematics. torch.ops.torchvision.nms is internal for loaded op and torchvision.ops.nms is external for python wrapper

Hi I am getting the same error. Can you please help me?

I must say I didn't managed to fix it (didn't had enough time to dig into torchscript custom ops naming rules). I think there's indeed a problem and I think the tests should fail on this issue. @fmassa as this is observed by other people, please take a look at it

Hi,

Can you print torch.__version__ and torchvision.__version__?

What is a bit confusing now is that torchvision nightly requires torch 1.3.0, and NOT a torch nightly, so this might be the reason

As I've mentioned in https://github.com/pytorch/vision/issues/1489, I'm going to be changing the torchvision nightlies to depend on PyTorch nightly.

torch: 1.4.0.dev20191016+cu100
torchvision: 0.5.0.dev20191017+cu100
I am using CUDA 10.0

I'll check 1.3.0, because I used torch nightly, but I reported this error before 1.3.0 release

Hi, I managed to find a compatible (working) pair of torchvision and torch.
torch: 1.3.0
torchvision: 0.4.1

The error indicates that there is an uncompatibility between the version of PyTorch that was used to build torchvision and the version of PyTorch that you are using (it's not clear from the message unfortunately)

I'm fixing things now so that torchvision nightly depend on PyTorch nightly, and I'll regenerate the binaries.

Fixed via #1492

Hi @fmassa , I am facing this issue on Windows using the latest stable build.

This is how I installed:

conda create -n pytorch
conda activate pytorch
conda install pytorch torchvision cudatoolkit=10.1 -c pytorch
conda list

Name | Version | Build | Channel
--- | ---| --- | --- |
blas | 1.0 | mkl |
ca-certificates | 2020.1.1 | 0 |
certifi | 2019.11.28 | py38_0 |
cudatoolkit | 10.1.243 | h74a9793_0 |
freetype | 2.9.1 | ha9979f8_1 |
icc_rt | 2019.0.0 | h0cc432a_1 |
intel-openmp | 2020.0 | 166 |
jpeg | 9b | hb83a4c4_2 |
libpng | 1.6.37 | h2a8f88b_0 |
libtiff | 4.1.0 | h56a325e_0 |
mkl | 2020.0 | 166 |
mkl-service | 2.3.0 | py38hb782905_0 |
mkl_fft | 1.0.15 | py38h14836fe_0 |
mkl_random | 1.1.0 | py38hf9181ef_0 |
ninja | 1.9.0 | py38h74a9793_0 |
numpy | 1.18.1 | py38h93ca92e_0 |
numpy-base | 1.18.1 | py38hc3f5095_1 |
olefile | 0.46 | py_0 |
openssl | 1.1.1d | he774522_4 |
pillow | 7.0.0 | py38hcc1f983_0 |
pip | 20.0.2 | py38_1 |
python | 3.8.1 | h5fd99cc_1 |
pytorch | 1.4.0 | py3.8_cuda101_cudnn7_0 | pytorch
setuptools | 45.2.0 | py38_0 |
six | 1.14.0 | py38_0 |
sqlite | 3.31.1 | he774522_0 |
tk | 8.6.8 | hfa6e2cd_0 |
torchvision | 0.5.0 | py38_cu101 | pytorch
vc | 14.1 | h0510ff6_4 |
vs2015_runtime | 14.16.27012 | hf0eaf9b_1 |
wheel | 0.34.2 | py38_0 |
wincertstore | 0.2 | py38_0 |
xz | 5.2.4 | h2fa13f4_4 |
zlib | 1.2.11 | h62dcd97_3 |
zstd | 1.3.7 | h508b16e_0 |

Tue Feb 18 15:08:03 2020
+-----------------------------------------------------------------------------+
| NVIDIA-SMI 436.48       Driver Version: 436.48       CUDA Version: 10.1     |
|-------------------------------+----------------------+----------------------+

And here is the error message:

Python 3.8.1 (default, Jan  8 2020, 15:55:49) [MSC v.1916 64 bit (AMD64)] :: Anaconda, Inc. on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import torch
>>> torch.ops.torchvision.nms
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Users\david\Miniconda3\envs\pytorch\lib\site-packages\torch\_ops.py", line 61, in __getattr__
    op = torch._C._jit_get_operation(qualified_op_name)
RuntimeError: No such operator torchvision::nms
>>>

What can I do ?

@davidsteinar - if you're still encountering this please create a new issue to gain visibility

same problem here

@FrancescoSaverioZuppichini see https://github.com/pytorch/vision/issues/1916

Oh thank you, fixed :)

I met the same erro:No such operator torchvision::nms.So I change the version of pytoch and torchvision to 1.2.0 and 0.4.0,but the erro is still here.
update(2020/4/21)
I hava solved this issue by changing the version of numpy from 1.18.1 to 1.17.0.

same on ArchLinux np is 1.19

torch.__version__: 1.6.0rc7
torchvision.__version__: 0.6.0a0

@chiboreache PyTorch 1.6.0 requires torchvision 0.7.0

@chiboreache PyTorch 1.6.0 requires torchvision 0.7.0

that really strange

in aur we only has 0.6.1-1

Screenshot_20200730_162700

@fmassa

git version actually was 0.8.0a0+f5bf9d5

it finally works again, thank you!

but i getting warning

/usr/lib/python3.8/site-packages/detectron2/layers/wrappers.py:226: UserWarning: This overload of nonzero is deprecated:
        nonzero()
Consider using one of the following signatures instead:
        nonzero(*, bool as_tuple) (Triggered internally at  ../torch/csrc/utils/python_arg_parser.cpp:766.)
  return x.nonzero().unbind(1)

is it torch or detektron2 issue?

this warning is expected, and was introduced in the latest release of PyTorch. detectron2 should update its implementation to use torch.nonzero(x, as_tuple=False).unbind(1)

@chiboreache PyTorch 1.6.0 requires torchvision 0.7
The problem didn't fixed even though I met the requirement

@GotFusion I believe the issue is still incompatibility of the versions -- you might be using a different python environment for running the code than the one you used for checking the versions

@GotFusion I believe the issue is still incompatibility of the versions -- you might be using a different python environment for running the code than the one you used for checking the versions

Thank you for your advice. I have changed the python version to 3.7.9, and it works now

torchvision 0.7.0

yes, I changed to 0.7.0, and it worked

Hey guys, I meet the same problem: RuntimeError: No such operator torchvision::nms with torch1.6 with torchvision0.7, and torch1.7 with torchvision0.8.1.
Then I modifty the code to such a way and it works:
from
torch.ops.torchvision.nms(boxes, scores, iou_thres)
to
import torchvision
torchvision.ops.nms(boxes, scores, iou_thres)
Hope this is helpful.

@feiyuhuahuo can you share where in the codebase / tutorials the torch.ops.torchvision.nms(boxes, scores, iou_thres version is used? The only version that we encourage users to use is torchvision.ops.nms(boxes, scores, iou_thres)

@feiyuhuahuo they should change their code, as this is not supported.

For torch.ops.torchvision to be available, we first need to import torchvision

@feiyuhuahuo I've commented in https://github.com/ultralytics/yolov5/issues/1272#issuecomment-731060257

@chiboreache PyTorch 1.6.0 requires torchvision 0.7.0

Thanks!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

I did like was noticed here but the new issues appeared later:
if expr.id == "True":
RecursionError: maximum recursion depth exceeded in comparison

Also, tried to downgrade version like:
pip3 install torch==1.4.0 torchvision==0.5.0 -f https://download.pytorch.org/whl/torch_stable.html -i https://pypi.tuna.tsinghua.edu.cn/simple

Alas, unsuccessfully

Was this page helpful?
0 / 5 - 0 ratings

Related issues

zhang-zhenyu picture zhang-zhenyu  路  3Comments

iacolippo picture iacolippo  路  4Comments

bodokaiser picture bodokaiser  路  3Comments

300LiterPropofol picture 300LiterPropofol  路  3Comments

xuanqing94 picture xuanqing94  路  3Comments