Skip to content

rocm/pytorch:latest broken: torchvision import crashes with 'operator torchvision::nms does not exist' #3109

@sunway513

Description

@sunway513

Summary

rocm/pytorch:latest Docker image ships a broken torchvision — import torchvision crashes immediately.

Reproducer

docker run --rm rocm/pytorch:latest python3 -c "import torchvision"

Error

Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/opt/venv/lib/python3.12/site-packages/torchvision/__init__.py", line 10, in <module>
    from torchvision import _meta_registrations, datasets, io, models, ops, transforms, utils
  File "/opt/venv/lib/python3.12/site-packages/torchvision/_meta_registrations.py", line 163, in <module>
    @torch.library.register_fake("torchvision::nms")
  File "/opt/venv/lib/python3.12/site-packages/torch/library.py", line 1062, in register
    use_lib._register_fake(
  File "/opt/venv/lib/python3.12/site-packages/torch/library.py", line 210, in _register_fake
    handle = entry.fake_impl.register(
  File "/opt/venv/lib/python3.12/site-packages/torch/_library/fake_impl.py", line 50, in register
    if torch._C._dispatch_has_kernel_for_dispatch_key(self.qualname, "Meta"):
RuntimeError: operator torchvision::nms does not exist

Versions in the image

torch:        2.9.1+rocm7.2.1.lw.gitff65f5bc
torchvision:  0.24.1
Python:       3.12

Impact

Root cause

torchvision's C++ extension (_C.so) does not have the custom ops (torchvision::nms, torchvision::roi_align, etc.) registered. This suggests torchvision was installed from a pre-built CPU-only wheel rather than being compiled from source against the ROCm torch build.

Suggested fix

Rebuild torchvision from source against the torch in the container, or install from the ROCm-compatible wheel index:

pip install --force-reinstall torchvision --index-url https://download.pytorch.org/whl/rocm7.2

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions