Fix ROCm torch install: use find-links, not --index-url (devcontainer, README, hip_utils) - #269
Conversation
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>
There was a problem hiding this comment.
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-urlto-f/--find-linkspointing at the Radeon ROCm wheel directory.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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>
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>
There was a problem hiding this comment.
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-urlwill likely continue to fail the same way (e.g., README.md and theflashinfer/hip_utils.pyerror message both point users at--index-url). Please update those references (or point at a true/simpleindex 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-urlis 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>
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>
There was a problem hiding this comment.
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_VERSIONexport and the uv/pip URL are built from{system_rocm}(oftenX.Y.Z), but the radeon directory naming isrocm-rel-X.Y. This guidance should use the already-computedsystem_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-urlfor the radeon wheel directory (e.g.,CLAUDE.md:42andpyproject.toml:19, plusamd-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_rocmis typically a 3-segment version (e.g.,7.2.0from/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"
Summary
Fix ROCm torch installation across the repo: point pip at the radeon wheel mirror with
-f/--find-linksinstead of--index-url, which fails withNo 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 theRUN.README.md— switch the two radeon torch install commands to-f, and rewrite the NOTE that previously recommended--index-urlso it reflects reality (why--index-urlfails, why-fstill 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-urlmakes pip request that path, so it finds zero candidates and fails.-f/--find-linksreads the flat listing directly, matching whatdocker/Dockerfile.rocm_cialready does.Switching to
-fstill 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 ranks2.9.1+rocm...strictly above PyPI's plain2.9.1, so pip selects it even though both satisfy==2.9.1. Confirmed withpip install --dry-run(resolved to the+rocm7.2.0wheel). 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
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 printedtorch 2.9.1+rocm7.2.0.git7e1940d4 (hip=7.2.26015-fc0010cf6a)before the build continued (proving the&&chain and the check both run).torch.version.hipset,torch.version.cudaNone), not a PyPI CUDA wheel.hip_utils.pychanges are text/guidance only; the repo's requiredpre-commitcheck runs on this PR in CI.