Skip to content

Implement ROCm version check (installed vs torch) - #15

Merged
jithunnair-amd merged 3 commits into
ROCm:mainfrom
rraminen:implement_TORCH_HIP_VERSION
Sep 28, 2026
Merged

jithunnair-amd merged 3 commits into
ROCm:mainfrom
rraminen:implement_TORCH_HIP_VERSION

Conversation

@rraminen

@rraminen rraminen commented May 13, 2026 •

Copy link
Copy Markdown

Summary

  • On ROCm, cuda_version() now reports the installed ROCm version from rocm-core/rocm_version.h (ROCM_VERSION_MAJOR * 100 + ROCM_VERSION_MINOR), instead of TORCH_HIP_VERSION.
  • _check_cuda_version() compares that value to torch.version.rocm (major.minor) and raises a clear error if PyTorch and TorchAudio were built for different ROCm versions, mirroring the existing CUDA check.
  • Removed unused -DTORCH_HIP_VERSION compile flags from tools/setup_helpers/extension.py.

Testing

Tested on ROCm 10.1. TorchAudio's native extension reported version 1001 (ROCm 10.1).
I simulated a mismatched PyTorch build by temporarily overriding torch.version.rocm:

python
from unittest import mock

import torch
import torchaudio
from torchaudio._extension.utils import _check_cuda_version

print("TorchAudio ROCm:", torch.ops._torchaudio.cuda_version())
print("PyTorch ROCm:", torch.version.rocm)

with mock.patch.object(torch.version, "rocm", "9.0.0"):
    _check_cuda_version()

Output:

TorchAudio ROCm: 1001
PyTorch ROCm: 10.1.0
Traceback (most recent call last):
  File "<stdin>", line 10, in <module>
  File "/opt/venv/lib/python3.12/site-packages/torchaudio/_extension/utils.py", line 136, in _check_cuda_version
    raise RuntimeError(
RuntimeError: Detected that PyTorch and TorchAudio were compiled with different ROCm versions. PyTorch has ROCm version 9.0 whereas TorchAudio has ROCm version 10.1. Please install the TorchAudio version that matches your PyTorch version.

@rraminen
rraminen marked this pull request as ready for review May 19, 2026 18:15
Comment thread src/libtorchaudio/utils.cpp Resolved
Comment thread src/torchaudio/_extension/utils.py Resolved
Comment thread src/libtorchaudio/utils.cpp Resolved
Comment thread tools/setup_helpers/extension.py Resolved
@jithunnair-amd jithunnair-amd changed the title Implement HIP build version using TORCH_HIP_VERSION Implement ROCm version check (installed vs torch) Aug 20, 2026
@jithunnair-amd
jithunnair-amd merged commit be9dd24 into ROCm:main Sep 28, 2026
5 of 50 checks passed
jithunnair-amd pushed a commit that referenced this pull request Oct 2, 2026
…20)

* Implement ROCm version check (installed vs torch) (#15)

* Use TORCH_HIP_VERSION

* Remove rocm version logic in extensions.py

* Compare installed ROCm to torch.version.rocm via rocm_version.h

* Remove rocm version logic in extensions.py

* Compare installed ROCm to torch.version.rocm via rocm_version.h
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants