Vision: Failed to register operator torchvision::_new_empty_tensor_op

Created on 28 Jan 2020  路  23Comments  路  Source: pytorch/vision

Trying to import
import torchvision
results in exception:

Traceback (most recent call last):
File "", line 1, in
File "/usr/local/lib/python3.6/dist-packages/torchvision/__init__.py", line 3, in
from torchvision import models
File "/usr/local/lib/python3.6/dist-packages/torchvision/models/__init__.py", line 12, in
from . import detection
File "/usr/local/lib/python3.6/dist-packages/torchvision/models/detection/__init__.py", line 1, in
from .faster_rcnn import *
File "/usr/local/lib/python3.6/dist-packages/torchvision/models/detection/faster_rcnn.py", line 7, in
from torchvision.ops import misc as misc_nn_ops
File "/usr/local/lib/python3.6/dist-packages/torchvision/ops/__init__.py", line 13, in
_register_custom_op()
File "/usr/local/lib/python3.6/dist-packages/torchvision/ops/_register_onnx_ops.py", line 49, in _register_custom_op
register_custom_op_symbolic('torchvision::_new_empty_tensor_op', new_empty_tensor_op, _onnx_opset_version)
File "/usr/local/lib/python3.6/dist-packages/torch/onnx/__init__.py", line 200, in register_custom_op_symbolic
return utils.register_custom_op_symbolic(symbolic_name, symbolic_fn, opset_version)
File "/usr/local/lib/python3.6/dist-packages/torch/onnx/utils.py", line 793, in register_custom_op_symbolic
.format(symbolic_name))
RuntimeError: Failed to register operator torchvision::_new_empty_tensor_op. The symbolic name must match the format Domain::Name, and sould start with a letter and contain only alphanumerical characters

Torchvision version (built from source): 0.6.0a0+28b7f8a
PyTorch version (built from source): 1.4.0a0+7f73f1d

build

Most helpful comment

If you want to use torchvision nightly, you need to use PyTorch nightly.

If you want to use a PyTorch from a release (say 1.4.0), you should use a torchvision from a matching release as well (in this case, 0.5.0)

All 23 comments

Hi,

You need a newer version of PyTorch to be able to compile latest torchvision (I had myself the same issue yesterday and an upgrade of PyTorch fixed it)

Hi,

You need a newer version of PyTorch to be able to compile latest torchvision (I had myself the same issue yesterday and an upgrade of PyTorch fixed it)

By newer you mean the nightly version?
He already uses 1.4 (And I got the same problem with v1.4.0)

Which torchvision should we use with pytorch v1.4.0?

I'm using PyTorch 1.4.0. During building torchvision (0.6.0a0+e2573a7) from source I see this message:

Searching for torch==1.4.0
Best match: torch 1.4.0
Adding torch 1.4.0 to easy-install.pth file

So it looks to me like torchvision depends on 1.4.0. Is that dependency not correct?

5ac5ab9ee83837faa81e7a104f5bd86b330c9fe6 seems to have introduced _new_empty_tensor_op which is the identifier that torch is complaining about. Rolling back torchvision to the parent commit, 40c99eae6d5cfa9f58bdf411242ea15b848eafb5, causes the import to succeed, and I was successful in running an image recognition demo.

@saareliad newer means a nightly version of PyTorch and torchvision. Using 1.4.0 and 0.5.0 is not enough.

If you want to use torchvision nightly, you need to use PyTorch nightly.

If you want to use a PyTorch from a release (say 1.4.0), you should use a torchvision from a matching release as well (in this case, 0.5.0)

I'm encountering the same problem on a linux server, nightly installed with pip:
pip install --pre torch torchvision -f https://download.pytorch.org/whl/nightly/cu101/torch_nightly.html

Solved by switching to python 3.7 (was 3.8 before).

edit: but gpu isn't detected as available (it is with upstream pytorch + torchvision).

@mknw can you open a new issue with the problem you are facing? From the description it seems that Python 3.8 with CUDa 10.1 is not working for our pip binaries, is that correct?

Can you also post when you tried downloading the binaries, and which version they are?

Hi,
I'm facing this issue on the lastest PyTorch version (1.5.0).

Traceback (most recent call last): File "main.py", line 14, in <module> from torchvision import transforms File "/home/alan/anaconda3/envs/cuongpx/lib/python3.6/site-packages/torchvision/__init__.py", line 3, in <module> from torchvision import models File "/home/alan/anaconda3/envs/cuongpx/lib/python3.6/site-packages/torchvision/models/__init__.py", line 12, in <module> from . import detection File "/home/alan/anaconda3/envs/cuongpx/lib/python3.6/site-packages/torchvision/models/detection/__init__.py", line 1, in <module> from .faster_rcnn import * File "/home/alan/anaconda3/envs/cuongpx/lib/python3.6/site-packages/torchvision/models/detection/faster_rcnn.py", line 7, in <module> from torchvision.ops import misc as misc_nn_ops File "/home/alan/anaconda3/envs/cuongpx/lib/python3.6/site-packages/torchvision/ops/__init__.py", line 13, in <module> _register_custom_op() File "/home/alan/anaconda3/envs/cuongpx/lib/python3.6/site-packages/torchvision/ops/_register_onnx_ops.py", line 51, in _register_custom_op register_custom_op_symbolic('torchvision::_new_empty_tensor_op', new_empty_tensor_op, _onnx_opset_version) File "/home/alan/anaconda3/lib/python3.6/site-packages/torch/onnx/__init__.py", line 195, in register_custom_op_symbolic return utils.register_custom_op_symbolic(symbolic_name, symbolic_fn, opset_version) File "/home/alan/anaconda3/lib/python3.6/site-packages/torch/onnx/utils.py", line 740, in register_custom_op_symbolic .format(symbolic_name)) RuntimeError: Failed to register operator torchvision::_new_empty_tensor_op. The symbolic name must match the format Domain::Name, and sould start with a letter and contain only alphanumerical characters
Environment
OS: Ubuntu 16.04.3 LTS (Xenial Xerus)"
PyTorch version: 1.5.0
torchvision version: 0.6.0
Python version: 3.6.9
CUDA version: 10.1

I have tried to degrade torchvision version to 0.5.0 but it raises another issue. How can I solve this issue?

Thanks

Seeing this error with Torchvision 0.6.0 (built from source) on ppc64le (CUDA 10.0) and x86-64 (CUDA 10.2) with PyTorch 1.4.0 (built from source), python 3.6.9 on Ubuntu 18.04. I'll attempt to downgrade TorchVision to 0.5.0 since ppc64le is currently broken with PyTorch 1.5.0.

UPDATE: Downgrading cleared this issue in x86-64, testing ppc64le
UPDATE2: Downgrade cleared it in ppc64le as well

Hi,

torchvision 0.6.0 is expected to work with PyTorch 1.5.0, and we don't guarantee that it will work with earlier versions of PyTorch

I resolved this with pip install --upgrade torch torchvision

torchvision 0.6.0 is expected to work with PyTorch 1.5.0, and we don't guarantee that it will work with earlier versions of PyTorch

Given how intertwined torchvision is with PyTorch, might not be a bad idea to enforce the torch version via requirements.txt, have a version compatibility chart documented (if it isn't already, didn't spot one), or base the version number of torchvision on its compatible version of PyTorch (assuming they are released in lockstep).

@qhaas that is a good point.
This should be fairly easy to do for stable versions of PyTorch / torchvision, but for the nightlies it might be a bit more complicated.

cc @seemethere for thoughts on how to enforce that the dependencies for the nightlies of PyTorch and torchvision align.

torchvision 0.6.0 is expected to work with PyTorch 1.5.0, and we don't guarantee that it will work with earlier versions of PyTorch

Given how intertwined torchvision is with PyTorch, might not be a bad idea to enforce the torch version via requirements.txt, have a version compatibility chart documented (if it isn't already, didn't spot one), or base the version number of torchvision on its compatible version of PyTorch (assuming they are released in lockstep).

This is actually already a requirement, per the wheel pkginfo:

> pkginfo -f requires_dist torchvision-0.6.0-cp38-cp38-manylinux1_x86_64.whl
requires_dist: ['numpy', 'torch (==1.5.0)', 'pillow (>=4.1.1)', "scipy ; extra == 'scipy'"]

Same goes for conda packages as well:

> conda search -c pytorch torchvision=0.6.0 -info
torchvision 0.6.0 py38_cu101
----------------------------
file name   : torchvision-0.6.0-py38_cu101.tar.bz2
name        : torchvision
version     : 0.6.0
build       : py38_cu101
build number: 0
size        : 11.8 MB
license     : BSD
subdir      : linux-64
url         : https://conda.anaconda.org/pytorch/linux-64/torchvision-0.6.0-py38_cu101.tar.bz2
md5         : 43374c8892abfc00f81c0ff2d62e2596
timestamp   : 2020-04-21 02:04:48 UTC
dependencies:
  - cudatoolkit >=10.1,<10.2
  - numpy >=1.11
  - pillow >=4.1.1
  - python >=3.8,<3.9.0a0
  - pytorch 1.5.0

Given how intertwined torchvision is with PyTorch, might not be a bad idea to enforce the torch version via requirements.txt, have a version compatibility chart documented (if it isn't already, didn't spot one), or base the version number of torchvision on its compatible version of PyTorch (assuming they are released in lockstep).

We should have something similar to torchtext's dependency matrix for all the domain libraries.
https://github.com/pytorch/text#installation

Facing this issue with:

torch==1.5.0+cpu
torchvision==0.6.0+cpu

Any suggestions?

@anurag25 please add more details for the error you are getting, and your system as well

I met the issue too. And my version info as below:

# Name                    Version                   Build  Channel
_pytorch_select           0.1                       cpu_0  
blas                      1.0                         mkl  
ca-certificates           2020.1.1                      0  
certifi                   2020.4.5.1               py37_0  
cffi                      1.14.0           py37hc512035_1  
intel-openmp              2019.4                      233  
libcxx                    10.0.0                        1  
libedit                   3.1.20181209         hb402a30_0  
libffi                    3.3                  h0a44026_1  
libgfortran               3.0.1                h93005f0_2  
mkl                       2019.4                      233  
mkl-service               2.3.0            py37hfbe908c_0  
mkl_fft                   1.0.15           py37h5e564d8_0  
mkl_random                1.1.1            py37h959d312_0  
ncurses                   6.2                  h0a44026_1  
ninja                     1.9.0            py37h04f5b5a_0  
numpy                     1.18.1           py37h7241aed_0  
numpy-base                1.18.1           py37h3304bdc_1  
openssl                   1.1.1g               h1de35cc_0  
pip                       20.0.2                   py37_3  
pycparser                 2.20                       py_0  
python                    3.7.7                hf48f09d_4  
pytorch                   1.4.0           cpu_py37hf9bb1df_0  
readline                  8.0                  h1de35cc_0  
setuptools                47.1.1                   py37_0  
six                       1.15.0                     py_0  
sqlite                    3.31.1               h5c1f38d_1  
tk                        8.6.8                ha441bb4_0  
wheel                     0.34.2                   py37_0  
xz                        5.2.5                h1de35cc_0  
zlib                      1.2.11               h1de35cc_3

The code is just some import:

import torch
import torchvision
import torchvision.transforms as transforms

Running it will get an error:
```
Traceback (most recent call last):
File "/Users/sheldon/vscodeProjects/Dive-into-DL-PyTorch/mycode/mnist3.5.py", line 2, in
import torchvision
File "/Users/sheldon/opt/anaconda3/lib/python3.7/site-packages/torchvision/__init__.py", line 3, in
from torchvision import models
File "/Users/sheldon/opt/anaconda3/lib/python3.7/site-packages/torchvision/models/__init__.py", line 12, in
from . import detection
File "/Users/sheldon/opt/anaconda3/lib/python3.7/site-packages/torchvision/models/detection/__init__.py", line 1, in
from .faster_rcnn import *
File "/Users/sheldon/opt/anaconda3/lib/python3.7/site-packages/torchvision/models/detection/faster_rcnn.py", line 7, in
from torchvision.ops import misc as misc_nn_ops
File "/Users/sheldon/opt/anaconda3/lib/python3.7/site-packages/torchvision/ops/__init__.py", line 13, in
_register_custom_op()
File "/Users/sheldon/opt/anaconda3/lib/python3.7/site-packages/torchvision/ops/_register_onnx_ops.py", line 51, in _register_custom_op
register_custom_op_symbolic('torchvision::_new_empty_tensor_op', new_empty_tensor_op, _onnx_opset_version)
File "/Users/sheldon/opt/anaconda3/lib/python3.7/site-packages/torch/onnx/__init__.py", line 200, in register_custom_op_symbolic
return utils.register_custom_op_symbolic(symbolic_name, symbolic_fn, opset_version)
File "/Users/sheldon/opt/anaconda3/lib/python3.7/site-packages/torch/onnx/utils.py", line 793, in register_custom_op_symbolic
.format(symbolic_name))
RuntimeError: Failed to register operator torchvision::_new_empty_tensor_op. The symbolic name must match the format Domain::Name, and sould start with a letter and contain only alphanumerical characters

```

Hi,

You need a newer version of PyTorch to be able to compile latest torchvision (I had myself the same issue yesterday and an upgrade of PyTorch fixed it)

I updated my torch into 1.5.0 version and my torchvision is 0..6.0, which were not able to updated further. Can you help me with this problem

Facing this issue with:

torch==1.5.0+cpu
torchvision==0.6.0+cpu

Any suggestions?

Have you ever fix this problem? I have same versions of torch and torchvision with you

Hi,

torchvision 0.6.0 is expected to work with PyTorch 1.5.0, and we don't guarantee that it will work with earlier versions of PyTorch

I have already the torch 1.5.0 and torchvsion 0.6.0, but it appears same

pip install --upgrade torch torchvision
Requirement already up-to-date: torch in /home/caine/anaconda3/lib/python3.7/site-packages (1.5.0)
Requirement already up-to-date: torchvision in /home/caine/anaconda3/lib/python3.7/site-packages (0.6.0)
Requirement already satisfied, skipping upgrade: future in /home/caine/anaconda3/lib/python3.7/site-packages (from torch) (0.18.2)
Requirement already satisfied, skipping upgrade: numpy in /home/caine/anaconda3/lib/python3.7/site-packages (from torch) (1.18.5)
Requirement already satisfied, skipping upgrade: pillow>=4.1.1 in /home/caine/anaconda3/lib/python3.7/site-packages (from torchvision) (7.1.2)

After several attempts to fix this problem, I find version of torch and torchvison should be matched. and the env cannot have other version of torch.

what i have done to fix this problem is uninstall torch and torchvision then use cmd
pip install --upgrade torch torchvision

bingo

Was this page helpful?
0 / 5 - 0 ratings

Related issues

martinarjovsky picture martinarjovsky  路  4Comments

ibtingzon picture ibtingzon  路  3Comments

a-maci picture a-maci  路  3Comments

zhang-zhenyu picture zhang-zhenyu  路  3Comments

chinglamchoi picture chinglamchoi  路  3Comments