Skip to content

Fix ROCm torch install: use find-links, not --index-url (devcontainer, README, hip_utils) - #269

Merged
demandal25 merged 5 commits into
amd-integrationfrom
fix/rocm-devcontainer-torch-findlinks
Jul 28, 2026
Merged

Fix ROCm torch install: use find-links, not --index-url (devcontainer, README, hip_utils)#269
demandal25 merged 5 commits into
amd-integrationfrom
fix/rocm-devcontainer-torch-findlinks

Conversation

@demandal25

@demandal25 demandal25 commented Jul 28, 2026

Copy link
Copy Markdown
Collaborator

Summary

Fix ROCm torch installation across the repo: point pip at the radeon wheel mirror with -f/--find-links instead of --index-url, which fails with No matching distribution found for torch==... (from versions: none). Started as a devcontainer build fix and extended to the user-facing install docs and error messages that carried the same broken command.

What changed

  • .devcontainer/rocm/Dockerfile — install torch with -f https://repo.radeon.com/rocm/manylinux/rocm-rel-${ROCM_VERSION}/ instead of --index-url; add a post-install assertion that fails the build if the installed torch is not a ROCm/HIP build (torch.version.hip is None); document the rationale in column-1 comments above the RUN.
  • README.md — switch the two radeon torch install commands to -f, and rewrite the NOTE that previously recommended --index-url so it reflects reality (why --index-url fails, why -f still selects the ROCm wheel, and how to verify).
  • flashinfer/hip_utils.py — switch the radeon torch commands in the "PyTorch has no ROCm support" error and the ROCm-version-mismatch warning (pip and uv variants) to -f.

Unrelated --index-url https://pypi.amd.com/simple/ lines (a real PEP 503 index) are intentionally left unchanged.

Why

repo.radeon.com/rocm/manylinux/rocm-rel-X.Y/ is a flat directory listing of wheels, not a PEP 503 simple index — its per-package path (.../torch/) returns 404. --index-url makes pip request that path, so it finds zero candidates and fails. -f/--find-links reads the flat listing directly, matching what docker/Dockerfile.rocm_ci already does.

Switching to -f still resolves to AMD's internal ROCm build rather than PyPI's CUDA wheel. The radeon wheel carries a local version (torch-2.9.1+rocm7.2.0.lw.git7e1940d4-cp312-cp312-linux_x86_64.whl), and PEP 440 ranks 2.9.1+rocm... strictly above PyPI's plain 2.9.1, so pip selects it even though both satisfy ==2.9.1. Confirmed with pip install --dry-run (resolved to the +rocm7.2.0 wheel). The devcontainer additionally guards this at build time with the HIP assertion, and the README documents a one-line check for manual installs.

Test plan

  • Built the image end to end: docker build --build-arg USER_UID=$(id -u) --build-arg USER_GID=$(id -g) --build-arg USERNAME=demandal -t dm-fi-rocm72-torch291-py312 -f .devcontainer/rocm/Dockerfile . — succeeds, and the HIP assertion printed torch 2.9.1+rocm7.2.0.git7e1940d4 (hip=7.2.26015-fc0010cf6a) before the build continued (proving the && chain and the check both run).
  • Verified torch inside the image is the ROCm build (torch.version.hip set, torch.version.cuda None), not a PyPI CUDA wheel.
  • README and hip_utils.py changes are text/guidance only; the repo's required pre-commit check runs on this PR in CI.

The radeon wheel mirror (repo.radeon.com/rocm/manylinux/rocm-rel-X.Y/) is a
flat directory listing, not a PEP 503 simple index — requesting the per-package
path (.../torch/) returns 404. With --index-url, pip therefore finds zero torch
candidates and fails with "No matching distribution found for torch==2.9.1
(from versions: none)".

Switch to -f/--find-links, matching docker/Dockerfile.rocm_ci. This still
resolves to AMD's internal ROCm build (torch 2.9.1+rocm7.2.0...) rather than
PyPI's CUDA wheel, because PEP 440 ranks the local-version wheel above the plain
2.9.1 on PyPI (verified with pip --dry-run and torch.version.hip in the image).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings July 28, 2026 04:27

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Updates the ROCm devcontainer image build to install the AMD ROCm PyTorch wheel from the Radeon wheel mirror correctly, by treating the mirror as a flat wheel directory rather than a PEP 503 “simple” index.

Changes:

  • Switch torch installation in the ROCm devcontainer from --index-url to -f/--find-links pointing at the Radeon ROCm wheel directory.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread .devcontainer/rocm/Dockerfile
Add a post-install assertion after the torch step that errors out when
torch.version.hip is None. With -f/--find-links, if the ROCm wheel were ever
missing for the pinned version/Python/platform, pip could silently fall back to
a PyPI CPU/CUDA wheel and leave the devcontainer broken; this makes that case a
hard build failure instead.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings July 28, 2026 04:50

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated 1 comment.

Comment thread .devcontainer/rocm/Dockerfile Outdated
The explanatory comment was indented inside the line-continued RUN chain, where
a mid-chain '#' is parsed ambiguously and can comment out the rest of the shell
command. Move it to Dockerfile comments above the RUN so the command chain (incl.
the HIP fail-fast check) stays intact.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings July 28, 2026 04:56

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated no new comments.

Comments suppressed due to low confidence (2)

.devcontainer/rocm/Dockerfile:90

  • Now that the devcontainer uses -f https://repo.radeon.com/.../rocm-rel-${ROCM_VERSION}/ (because the URL is not a PEP 503 simple index), repo documentation and user-facing guidance that still recommends --index-url will likely continue to fail the same way (e.g., README.md and the flashinfer/hip_utils.py error message both point users at --index-url). Please update those references (or point at a true /simple index if one exists) so users don’t hit the same torch install failure outside the devcontainer.
    /bin/micromamba run -n ${MAMBA_ENV_NAME} pip install --no-cache-dir torch==${TORCH_VERSION} -f https://repo.radeon.com/rocm/manylinux/rocm-rel-${ROCM_VERSION}/ && \
    /bin/micromamba run -n ${MAMBA_ENV_NAME} python -c "import torch, sys; hip = torch.version.hip; print(f'torch {torch.__version__} (hip={hip})'); sys.exit('ERROR: installed torch has no ROCm/HIP build (hip is None)' if hip is None else 0)" && \

.devcontainer/rocm/Dockerfile:86

  • The Dockerfile switches to -f/--find-links, but the in-file comment only explains the HIP build assertion; it doesn't record why --index-url is intentionally avoided here. Given the repo has multiple places that recommend --index-url, capturing the PEP 503/flat-directory rationale inline will help prevent accidental reverts and future confusion.

This issue also appears on line 89 of the same file.

# Create a new micromamba env and install needed packages for flashinfer development.
# After installing torch, assert it is a ROCm/HIP build (torch.version.hip is not
# None) so the build fails fast if -f/--find-links ever resolves a PyPI CPU/CUDA
# wheel instead of the radeon ROCm wheel.

Record the PEP 503 / flat-directory rationale inline so the -f/--find-links
choice isn't accidentally reverted to --index-url (which 404s against the flat
radeon wheel repo).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings July 28, 2026 05:05

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated no new comments.

README and the hip_utils torch-missing/mismatch messages told users to run
`pip install torch ... --index-url https://repo.radeon.com/.../rocm-rel-X.Y/`,
which fails ("No matching distribution found") because that repo is a flat wheel
listing, not a PEP 503 simple index. Switch the radeon torch commands to
`-f`/`--find-links` (matching the devcontainer Dockerfile and Dockerfile.rocm_ci).

The pip still resolves the ROCm build over a same-version PyPI wheel because the
`+rocm<X.Y>` local version ranks higher; the README NOTE that previously argued
for --index-url is updated to explain this and to suggest verifying
`torch.version.hip`. The unrelated pypi.amd.com/simple/ index-url lines (a real
simple index) are left unchanged.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings July 28, 2026 14:39
@demandal25 demandal25 changed the title Fix ROCm devcontainer torch install: use find-links, not --index-url Fix ROCm torch install: use find-links, not --index-url (devcontainer, README, hip_utils) Jul 28, 2026

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated no new comments.

Comments suppressed due to low confidence (3)

flashinfer/hip_utils.py:567

  • Same version-format issue as above: the FLASHINFER_ROCM_VERSION export and the uv/pip URL are built from {system_rocm} (often X.Y.Z), but the radeon directory naming is rocm-rel-X.Y. This guidance should use the already-computed system_rocm_major_minor.
                f"  export FLASHINFER_ROCM_VERSION={system_rocm}\n"
                f"  uv pip install torch==2.7.1 -f "
                f"https://repo.radeon.com/rocm/manylinux/rocm-rel-{system_rocm}/\n"

README.md:151

  • The PR description says the broken --index-url https://repo.radeon.com/rocm/manylinux/... usage was fixed “across the repo”, but there are still examples that recommend --index-url for the radeon wheel directory (e.g., CLAUDE.md:42 and pyproject.toml:19, plus amd-flashinfer-jit-cache/pyproject.toml:4,33). This leaves conflicting installation guidance within the same repo.
**NOTE:** The radeon repo is a flat wheel listing, not a PEP 503 index, so
`--index-url` fails with "No matching distribution found" — use `-f`
(`--find-links`). pip still prefers the ROCm wheel over a same-version PyPI
wheel because its `+rocm<X.Y>` local version ranks higher. Confirm the result
with `python -c "import torch; assert torch.version.hip, 'not a ROCm build'"`.

flashinfer/hip_utils.py:563

  • system_rocm is typically a 3-segment version (e.g., 7.2.0 from /opt/rocm/.info/version), but the radeon wheel directories are major.minor (e.g., rocm-rel-7.2). The warning currently builds a URL with {system_rocm}, which can point users to a non-existent directory.

This issue also appears on line 565 of the same file.

                f"  pip install torch==2.7.1 -f "
                f"https://repo.radeon.com/rocm/manylinux/rocm-rel-{system_rocm}/\n\n"

@demandal25
demandal25 merged commit 3e7e5df into amd-integration Jul 28, 2026
2 checks passed
@demandal25
demandal25 deleted the fix/rocm-devcontainer-torch-findlinks branch July 28, 2026 16:21
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