vision: RuntimeError: No such operator torchvision::nms

🐛 Bug

Ran into this issue when trying to use Faster R-CCC example on a Windows machine. RuntimeError: No such operator torchvision::nms

To Reproduce

Steps to reproduce the behavior:

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

and then

>>> 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

Expected behavior

To be able to use torchvision.nms …

Environment

Collecting environment information...
PyTorch version: 1.4.0
Is debug build: No
CUDA used to build PyTorch: 10.1

OS: Microsoft Windows 10 Pro
GCC version: Could not collect
CMake version: Could not collect

Python version: 3.8
Is CUDA available: Yes
CUDA runtime version: 10.0.130
GPU models and configuration: GPU 0: GeForce GTX 1070
Nvidia driver version: 436.48
cuDNN version: C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v10.0\bin\cudnn64_7.dll

Versions of relevant libraries:
[pip3] numpy==1.17.4
[pip3] torch==1.4.0
[pip3] torchvision==0.5.0
[conda] blas                      1.0                         mkl
[conda] mkl                       2020.0                      166
[conda] mkl-service               2.3.0            py38hb782905_0
[conda] mkl_fft                   1.0.15           py38h14836fe_0
[conda] mkl_random                1.1.0            py38hf9181ef_0
[conda] pytorch                   1.4.0           py3.8_cuda101_cudnn7_0    pytorch
[conda] torchvision               0.5.0                py38_cu101    pytorch

and

nvidia-smi
Tue Feb 25 15:39:48 2020
+-----------------------------------------------------------------------------+
| NVIDIA-SMI 436.48       Driver Version: 436.48       CUDA Version: 10.1     |
|-------------------------------+----------------------+----------------------+

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Reactions: 3
  • Comments: 24 (11 by maintainers)

Commits related to this issue

Most upvoted comments

It seems that when I do

conda create -n torch
conda activate torch
python -V

I get Python 3.6.8

Then when I do

conda install pytorch torchvision cudatoolkit=10.1 -c pytorch
python -V

I get Python 3.8.1. This environment produces the RuntimeError: No such operator torchvision::nms

But

if I specifically create a python 3.7 environment

conda create -n torch37 python=3.7
conda activate torch37
python -V

I get Python 3.7.6

Then

conda install pytorch torchvision cudatoolkit=10.1 -c pytorch
python -V

I also get Python 3.7.6. In this environment I get no error

import torch
import torchvision
torch.ops.torchvision.nms
>>> <built-in method nms of PyCapsule object at 0x00000201B0AC9FC0>

So the issue seems to be with conda install pytorch torchvision cudatoolkit=10.1 -c pytorch choosing python 3.8 and causing this issue…

In Python 3.6 the solution will give the error:

AttributeError: module ‘os’ has no attribute ‘add_dll_directory’

So I solved my issue adding this before importing torch and torchvision:

import os
import sys
py_dll_path = os.path.join(sys.exec_prefix, 'Library', 'bin')
os.environ['PATH'] += py_dll_path

You mean it’s Python 3.8 only issue, right? I’ll check later.

I also encounter the same issue. In my case, nvidia-smi: CUDA 11.0 and I installed pytorch using torchtoolkit 10.1. So in order to solve, use this command: conda install pytorch torchvision torchaudio cudatoolkit=11.0 -c pytorch Hope this helps

Solved. In my case the error occurred because I used different machines with different GPUs for building torchvision and running training.

Specifying CUDA compute capability such as TORCH_CUDA_ARCH_LIST="6.0;6.1;7.0" when building torchvision resolved this.