Skip to content

[release/2.11.0.2] Implement ROCm version check (installed vs torch) - #20

Merged
jithunnair-amd merged 3 commits into
release/2.11.0.2from
rraminen/cherrypick_pr15_release_2.11.0.2
Oct 2, 2026
Merged

jithunnair-amd merged 3 commits into
release/2.11.0.2from
rraminen/cherrypick_pr15_release_2.11.0.2

Conversation

@rraminen

@rraminen rraminen commented Oct 1, 2026

Copy link
Copy Markdown

This PR is to cherry-pick the commits from #15 PR into release/2.11.0.2 branch.

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 and others added 3 commits September 28, 2026 12:47
* Use TORCH_HIP_VERSION

* Remove rocm version logic in extensions.py

* Compare installed ROCm to torch.version.rocm via rocm_version.h
@jithunnair-amd
jithunnair-amd merged commit 289149b into release/2.11.0.2 Oct 2, 2026
@jithunnair-amd
jithunnair-amd deleted the rraminen/cherrypick_pr15_release_2.11.0.2 branch October 2, 2026 21:51
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