Repository navigation
feat(docker): add an AMD ROCm image, for RDNA2 through RDNA4 and CDNA - #10820
danielhanchen merged 20 commits into
Conversation
Reapplies PR unslothai#6231 on top of main. Dockerfile.rocm, Dockerfile.studio-rocm, entrypoint-rocm.sh, smoke_test_rocm.py, test_locally-rocm.sh and the publish workflow are unchanged from that branch. build.sh and run.sh were rewritten by unslothai#5748 after unslothai#6231 was opened, so the --rocm hooks are reimplemented against the current files instead of merged: run.sh now reuses main's numeric --group-add gid lookup, and skips the NVIDIA toolkit prompt on the ROCm path.
Two defects found by building the image: The torch layer used --index-strategy unsafe-best-match with pypi as a fallback, which compares versions across both indexes. Every ROCm index below 7.2 trails pypi's torch (rocm6.2 tops out at 2.5.1, rocm6.4 at 2.9.1), so the best match is pypi's CUDA build: the PR's own default of rocm6.2 resolves to a plain torch==2.14.0 pulling nvidia-cublas and nccl, and then fails the torch.version.hip assertion. Dropped the fallback and moved the --rocm default to 7.2.4, which is also the floor for RDNA4. unsloth-zoo and cut-cross-entropy both declare a bare triton on Linux, the NVIDIA-targeted pypi wheel. It installs over torch's triton-rocm in the same site-packages/triton/, leaving triton 3.8.0 by metadata and triton.__version__ 3.7.1 in one tree. Uninstall it and reinstall the pin torch names.
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
Checked the --rocm hooks in docker/build.sh and docker/run.sh and the existing NVIDIA path stays gated behind the non-ROCm branch, which is the right shape. Since Dockerfile.studio-rocm has not been built and you flagged the SKIP_TORCH and BASE_TAG issues yourself, could you drop it to a follow-up so this lands as the base ROCm image only? |
|
Part of this is not yours. Two failures are from this PR's own new files, and both gates are telling you the fix:
Rebase once #10832 is in. |
|
Checked the --rocm hooks in docker/run.sh and docker/build.sh, and the ROCm wheel index change looks right, but this also reshapes the NVIDIA branch of run.sh (GPU_FLAG, the toolkit prompt and the AMD device passthrough inside host_has_nvidia), so could you confirm a plain |
|
The ROCm base image and the --rocm hooks in docker/run.sh read well, but Dockerfile.studio-rocm has never been built and its ENV SKIP_TORCH=true and ARG BASE_TAG=test do not match what build.sh produces, so could you drop the Studio variant to a follow-up and keep this to the base image? Also, since nothing here has run on a real AMD GPU yet, could you get the 5-step LoRA smoke test through on a KFD host before I review? |
…per-arch ROCM_GFX builds, version-aware entrypoint, frozen workflow refs, host-side tests
|
@codex security review |
…images drop a stale gfx override
…spatch allowed; sha build args documented
…and get the gfx tag only there
|
Codex Review: Didn't find any major issues. Keep them coming! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
…CUDA image does (#11286) The ROCm Studio image from #11218 runs Studio alone, so an AMD user who follows the Docker quickstart has nowhere to open a notebook. The CUDA core image already carries JupyterLab, the notebook tooling and the notebooks, which Dockerfile.studio inherits; the ROCm base carries none of it, so Dockerfile.studio-rocm installs it itself, piece by piece against the CUDA files, with a suite pinning the two together. supervisord and studio_launch.sh are not new here: both are already on main driving the CUDA Studio image, and this points the ROCm image at them rather than adding a second way to run two services in one container. An earlier revision also enabled key-only sshd on :22. That rode along with the notebooks and had no argument of its own, so it was stripped: openssh-server is not installed, EXPOSE is 8000 8888, and studio_launch.sh's existing `command -v sshd` gate keeps the shared supervisord program down. The org Actions queue is 200+ runs deep, so this PR's own checks never reported. Run on staging instead: 70 passed on ubuntu-latest and on macos-15, and the full repo suite at 8034 + 11465 passed. Eight failures there, seven of which reproduce on a clean origin/main worktree and one of which pre-commit.ci fixed on the branch. The windows-latest leg errors on an unguarded os.geteuid() that has been in tests/python/test_docker_rocm.py since #10820, byte-identical on main; fixed separately in #11457. Not verified: the GPU. The author's run went through Docker Desktop's /dev/dxg, where the torch wheel's bundled HSA runtime has no DXG path, so torch.cuda.is_available() was False and no notebook in this image has trained. Closes #11235
…CUDA image does (unslothai#11286) The ROCm Studio image from unslothai#11218 runs Studio alone, so an AMD user who follows the Docker quickstart has nowhere to open a notebook. The CUDA core image already carries JupyterLab, the notebook tooling and the notebooks, which Dockerfile.studio inherits; the ROCm base carries none of it, so Dockerfile.studio-rocm installs it itself, piece by piece against the CUDA files, with a suite pinning the two together. supervisord and studio_launch.sh are not new here: both are already on main driving the CUDA Studio image, and this points the ROCm image at them rather than adding a second way to run two services in one container. An earlier revision also enabled key-only sshd on :22. That rode along with the notebooks and had no argument of its own, so it was stripped: openssh-server is not installed, EXPOSE is 8000 8888, and studio_launch.sh's existing `command -v sshd` gate keeps the shared supervisord program down. The org Actions queue is 200+ runs deep, so this PR's own checks never reported. Run on staging instead: 70 passed on ubuntu-latest and on macos-15, and the full repo suite at 8034 + 11465 passed. Eight failures there, seven of which reproduce on a clean origin/main worktree and one of which pre-commit.ci fixed on the branch. The windows-latest leg errors on an unguarded os.geteuid() that has been in tests/python/test_docker_rocm.py since unslothai#10820, byte-identical on main; fixed separately in unslothai#11457. Not verified: the GPU. The author's run went through Docker Desktop's /dev/dxg, where the torch wheel's bundled HSA runtime has no DXG path, so torch.cuda.is_available() was False and no notebook in this image has trained. Closes unslothai#11235
adds an AMD ROCm image alongside the CUDA one from #5748. same
docker/layout, samebuild.sh/run.shentry points, same smoke-test shape.this is #6231 resynced. that PR targeted
docker-blackwell-build, which was deleted when #5748 merged, so github auto-closed it and won't reopen it. the branch was also 2764 commits behind, andbuild.sh/run.shwere rewritten underneath it, so the--rocmhooks are reimplemented against the current files rather than merged.what's here
docker/Dockerfile.rocm: ROCm torch wheels plus the bitsandbytes pre-release that carries the 4-bit decode fix.[huggingface]extra, SDPA fallback, since xformers has no ROCm wheel.docker/Dockerfile.studio-rocm: Studio variant on the ROCm base.docker/entrypoint-rocm.sh: preflight for/dev/kfd, rocm-smi, HIP torch, gfx arch.docker/smoke_test_rocm.py: ROCm smoke test with a 5-step LoRA..github/workflows/docker-publish-rocm.yml: GPU-free amd64 build and publish.build.sh --rocmandrun.sh --rocm.run.shreuses main's numeric--group-addgid lookup instead of passing the group by name, and skips the NVIDIA toolkit prompt on the ROCm path.two things building it turned up
the old default installed a CUDA torch. the torch layer used
--index-strategy unsafe-best-matchwith pypi as a fallback, which compares versions across both indexes. every ROCm wheel index below 7.2 trails pypi, so pypi won:rocm6.4 does the same thing (
2.14.0vs2.9.1+rocm6.4). the build then failed its ownassert torch.version.hip is not None. dropped the pypi fallback, and moved the default to ROCm 7.2.4: 6.2 tops out at torch 2.5.1, which current unsloth-zoo and transformers won't sit on, and RDNA4 has no kernels before 7.x anyway.the image shipped two tritons in one directory. unsloth-zoo and cut-cross-entropy each declare a bare
tritonon linux, which is the NVIDIA-targeted pypi wheel, and it installs over torch'striton-rocmin the samesite-packages/triton/:neither version describes what's actually on disk. uninstalling the pypi one and reinstalling the pin torch names fixes it:
index selection can't fix this,
download.pytorch.org/whl/rocm7.2/triton/is the pypi wheel mirrored rather than a ROCm build. the durable fix is probably in unsloth-zoo's metadata, where that dependency should be conditional.hardware and OS coverage
no hosted github runner has an AMD GPU, and the self-hosted Strix Halo runner on ooba's fork is the wrong arch and OS for this, so a green check here says nothing about AMD behaviour. this table is the test report.
measured at 8ee07d6.
docker/is unchanged on main since that commit.HSA_OVERRIDE_GFX_VERSIONwhere it was run:
run.sh --rocmend to end, and 58 existing docker tests. it can prove nothing about a GPUwindows can't test the GPU half of this, and the reason is structural. Docker Desktop's WSL2 backend has no
/dev/kfdand no/dev/dri, only/dev/dxg. the host's own WSL ubuntu does see the card through DXG because its ROCm shipslibrocdxg.so; therocm/dev-ubuntu-22.04base images don't ship that shim, and mounting the host's copy in still segfaults rocminfo. so no flag combination gets this image onto a GPU there. the entrypoint currently tells such a user tomodprobe amdgpu, which is impossible on that host, and that message should say so.bottom line
solid: the image builds, the wheel resolution is correct on every ROCm index, the triton tree is consistent, and every failure path refuses clearly rather than half-working.
biggest gap: not one line of this has run on a GPU.
Dockerfile.studio-rocmhas never been built even once, and has two problems that don't need hardware to see.ENV SKIP_TORCH=truedoes nothing, install.sh derives that from--no-torch/UNSLOTH_NO_TORCHand sets it false unconditionally, so install.sh re-runs torch selection against an absent build-host GPU. andARG BASE_TAG=testdoesn't match the:latestthatbuild.sh --rocmproduces. happy to fix both, or drop the Studio image from this PR and do it separately.closes #6230 when it lands. supersedes #6231.