Runtime error: torchvision::nms does not exist

Description:

When importing torchvision in Python, the following error shows:

---------------------------------------------------------------------------
RuntimeError                              Traceback (most recent call last)
Cell In[1], line 1
----> 1 import torchvision

File /usr/lib/python3.12/site-packages/torchvision/__init__.py:6
      3 from modulefinder import Module
      5 import torch
----> 6 from torchvision import _meta_registrations, datasets, io, models, ops, transforms, utils
      8 from .extension import _HAS_OPS
     10 try:

File /usr/lib/python3.12/site-packages/torchvision/_meta_registrations.py:163
    153     torch._check(
    154         grad.dtype == rois.dtype,
    155         lambda: (
   (...)
    158         ),
    159     )
    160     return grad.new_empty((batch_size, channels, height, width))
--> 163 @torch._custom_ops.impl_abstract("torchvision::nms")
    164 def meta_nms(dets, scores, iou_threshold):
    165     torch._check(dets.dim() == 2, lambda: f"boxes should be a 2d tensor, got {dets.dim()}D")
    166     torch._check(dets.size(1) == 4, lambda: f"boxes should have 4 elements in dimension 1, got {dets.size(1)}")

File /usr/lib/python3.12/site-packages/torch/library.py:467, in impl_abstract.<locals>.inner(func)
    464 else:
    465     func_to_register = func
--> 467 handle = entry.abstract_impl.register(func_to_register, source)
    468 if lib is not None:
    469     lib._registration_handles.append(handle)

File /usr/lib/python3.12/site-packages/torch/_library/abstract_impl.py:30, in AbstractImplHolder.register(self, func, source)
     24 if self.kernel is not None:
     25     raise RuntimeError(
     26         f"impl_abstract(...): the operator {self.qualname} "
     27         f"already has an abstract impl registered at "
     28         f"{self.kernel.source}."
     29     )
---> 30 if torch._C._dispatch_has_kernel_for_dispatch_key(self.qualname, "Meta"):
     31     raise RuntimeError(
     32         f"impl_abstract(...): the operator {self.qualname} "
     33         f"already has an DispatchKey::Meta implementation via a "
   (...)
     36         f"impl_abstract."
     37     )
     39 if torch._C._dispatch_has_kernel_for_dispatch_key(
     40     self.qualname, "CompositeImplicitAutograd"
     41 ):

RuntimeError: operator torchvision::nms does not exist

Additional info:

  • package version(s): python-torchvision-cuda 0.17.1-2
  • config and/or log files: None
  • link to upstream bug report, if any: None

Steps to reproduce:

  1. Install python-torchvision-cuda
  2. Import torchvision in Python
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information