Skip to content

Commit b353d2d

Browse files
committed
Add ROCm CI job
1 parent 6107b08 commit b353d2d

1 file changed

Lines changed: 134 additions & 0 deletions

File tree

.github/workflows/linux_rocm.yaml

Lines changed: 134 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,134 @@
1+
name: Linux ROCm x86
2+
3+
on:
4+
pull_request:
5+
push:
6+
branches:
7+
- nightly
8+
- main
9+
- release/*
10+
tags:
11+
- v[0-9]+.[0-9]+.[0-9]+-rc[0-9]+
12+
- v[0-9]+.[0-9]+.[0-9]+
13+
workflow_dispatch:
14+
15+
concurrency:
16+
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref_name }}-${{ github.ref_type == 'branch' && github.sha }}-${{ github.event_name == 'workflow_dispatch' }}
17+
cancel-in-progress: true
18+
19+
permissions:
20+
id-token: write
21+
contents: read
22+
23+
defaults:
24+
run:
25+
shell: bash -l -eo pipefail {0}
26+
27+
jobs:
28+
generate-matrix:
29+
uses: pytorch/test-infra/.github/workflows/generate_binary_build_matrix.yml@main
30+
with:
31+
package-type: wheel
32+
os: linux
33+
test-infra-repository: pytorch/test-infra
34+
test-infra-ref: main
35+
with-cpu: disable
36+
with-xpu: disable
37+
with-cuda: disable
38+
with-rocm: enable
39+
build-python-only: "disable"
40+
41+
build:
42+
needs: generate-matrix
43+
strategy:
44+
fail-fast: false
45+
name: Build and Upload wheel
46+
uses: pytorch/test-infra/.github/workflows/build_wheels_linux.yml@main
47+
with:
48+
repository: meta-pytorch/torchcodec
49+
ref: ""
50+
test-infra-repository: pytorch/test-infra
51+
test-infra-ref: main
52+
build-matrix: ${{ needs.generate-matrix.outputs.matrix }}
53+
pre-script: packaging/pre_build_script.sh
54+
post-script: packaging/post_build_script.sh
55+
smoke-test-script: packaging/fake_smoke_test.py
56+
package-name: torchcodec
57+
trigger-event: ${{ github.event_name }}
58+
build-platform: "python-build-package"
59+
# CPU-only compile: we build against torch-ROCm, but no ROCm/GPU decode
60+
# sources exist yet (rocJPEG is a follow-up), so ENABLE_CUDA/ENABLE_ROCM
61+
# are intentionally unset and this produces a CPU-only wheel.
62+
build-command: "BUILD_AGAINST_ALL_FFMPEG_FROM_S3=1 python -m build --wheel -vvv --no-isolation"
63+
64+
install-and-test:
65+
# ROCm runners are not on EC2 and authenticate to AWS (ECR) via GitHub OIDC.
66+
# Fork PRs don't get an OIDC id-token from GitHub, so the job can't pull the
67+
# docker image and always fails. Skip it for fork PRs; it still runs on
68+
# same-repo PRs, push, and workflow_dispatch.
69+
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository
70+
needs: build
71+
strategy:
72+
fail-fast: false
73+
matrix:
74+
python-version: ['3.10']
75+
rocm-version: ['7.1']
76+
ffmpeg-version-for-tests: ['7']
77+
uses: pytorch/test-infra/.github/workflows/linux_job_v2.yml@main
78+
permissions:
79+
id-token: write
80+
contents: read
81+
with:
82+
repository: meta-pytorch/torchcodec
83+
runner: "linux.rocm.gpu.gfx942.1"
84+
gpu-arch-type: "rocm"
85+
gpu-arch-version: ${{ matrix.rocm-version }}
86+
# ROCm self-hosted runners are not on EC2, so they can't pull the default
87+
# ECR-hosted docker image (no AWS credentials). Use a Docker Hub image and
88+
# run without sudo, matching pytorch/vision's ROCm job.
89+
docker-image: pytorch/manylinux2_28-builder:rocm${{ matrix.rocm-version }}
90+
no-sudo: true
91+
timeout: 120
92+
test-infra-ref: main
93+
download-artifact: meta-pytorch_torchcodec__${{ matrix.python-version }}_rocm${{ matrix.rocm-version }}_x86_64
94+
script: |
95+
set -euo pipefail
96+
97+
python -m pip install --upgrade pip
98+
99+
echo '::group::Install PyTorch (ROCm)'
100+
pip install --progress-bar=off --pre torch \
101+
--index-url https://download.pytorch.org/whl/nightly/rocm${{ matrix.rocm-version }}
102+
echo '::endgroup::'
103+
104+
echo '::group::Assert we are on ROCm'
105+
rocm-smi
106+
python -c "
107+
import torch
108+
print('torch:', torch.__version__, '| hip:', torch.version.hip)
109+
assert torch.version.hip is not None, 'torch is not a ROCm/HIP build'
110+
assert torch.cuda.is_available(), 'no GPU visible to torch'
111+
print('device:', torch.cuda.get_device_name(0))
112+
"
113+
echo '::endgroup::'
114+
115+
# Prevent the checked-out src/ tree from shadowing the installed wheel.
116+
bash packaging/remove_src.sh
117+
118+
echo '::group::Install torchcodec from the wheel'
119+
python -m pip install "${RUNNER_ARTIFACT_DIR}"/*.whl -vvv
120+
echo '::endgroup::'
121+
122+
echo '::group::Install FFmpeg and test dependencies'
123+
bash packaging/install_ffmpeg.sh ${{ matrix.ffmpeg-version-for-tests }}
124+
bash packaging/install_test_dependencies.sh
125+
echo '::endgroup::'
126+
127+
echo '::group::Run Python tests'
128+
# torch.cuda.is_available() is True on ROCm (HIP masquerades as CUDA), so
129+
# conftest.py won't auto-skip needs_cuda tests. This wheel has no GPU
130+
# decode compiled, so we deselect them explicitly. When the rocJPEG
131+
# decoder lands, its GPU tests get wired in here.
132+
FAIL_WITHOUT_JPEG=1 FAIL_WITHOUT_PNG=1 FAIL_WITHOUT_WEBP=1 FAIL_WITHOUT_AVIF=1 \
133+
pytest -m "not needs_cuda" --override-ini="addopts=-v" test --tb=short
134+
echo '::endgroup::'

0 commit comments

Comments
 (0)