Uploaded image for project: 'AI Platform Core Components'
  1. AI Platform Core Components
  2. AIPCC-4818

torchaudio - failed to import on ROCm

    • Icon: Bug Bug
    • Resolution: Done
    • Icon: Critical Critical
    • None
    • None
    • Accelerator Enablement
    • None
    • AIPCC Accelerators 14

      Importing torchaudio package failed on ROCm with the following error. It is looking for libtorch_cuda.so instead of libtorch_hip.so that is present on the system. This issue was noticed as part of testing vllm-0.10.0 on ROCm.

      
      (.venv) (app-root) /work$ python
      Python 3.12.9 (main, Jun 20 2025, 00:00:00) [GCC 11.5.0 20240719 (Red Hat 11.5.0-5)] on linux
      Type "help", "copyright", "credits" or "license" for more information.
      >>> import torchaudio
      Traceback (most recent call last):
      File "<stdin>", line 1, in <module>
      File "/opt/app-root/.venv/lib64/python3.12/site-packages/torchaudio/__init__.py", line 2, in <module>
          from . import _extension  # noqa  # usort: skip
          ^^^^^^^^^^^^^^^^^^^^^^^^
      File "/opt/app-root/.venv/lib64/python3.12/site-packages/torchaudio/_extension/__init__.py", line 38, in <module>
          _load_lib("libtorchaudio")
      File "/opt/app-root/.venv/lib64/python3.12/site-packages/torchaudio/_extension/utils.py", line 60, in _load_lib
          torch.ops.load_library(path)
      File "/opt/app-root/.venv/lib64/python3.12/site-packages/torch/_ops.py", line 1392, in load_library
          ctypes.CDLL(path)
      File "/usr/lib64/python3.12/ctypes/__init__.py", line 379, in __init__
          self._handle = _dlopen(self._name, mode)
                         ^^^^^^^^^^^^^^^^^^^^^^^^^
        OSError: libtorch_cuda.so: cannot open shared object file: No such file or directory

      The latest base image from quay (quay.io/aipcc/base-images/rocm) was used for testing and wheels were installed from the builder cache https://gitlab.com/api/v4/projects/72176068/packages/pypi/simple/

      On the same system, in a different virtual environment, I installed upstream torchaudio (2.7.1) wheel and the import didn't give any error.

              emacchi@redhat.com Emilien Macchi
              rh-ee-aayikkar Aparna Ayikkara
              Frank's Team
              Votes:
              0 Vote for this issue
              Watchers:
              6 Start watching this issue

                Created:
                Updated:
                Resolved: