-
Notifications
You must be signed in to change notification settings - Fork 121
172 lines (155 loc) · 7.14 KB
/
Copy pathlinux_rocm.yaml
File metadata and controls
172 lines (155 loc) · 7.14 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
name: Linux ROCm x86
on:
pull_request:
push:
branches:
- nightly
- main
- release/*
tags:
- v[0-9]+.[0-9]+.[0-9]+-rc[0-9]+
- v[0-9]+.[0-9]+.[0-9]+
workflow_dispatch:
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref_name }}-${{ github.ref_type == 'branch' && github.sha }}-${{ github.event_name == 'workflow_dispatch' }}
cancel-in-progress: true
permissions:
id-token: write
contents: read
defaults:
run:
shell: bash -l -eo pipefail {0}
jobs:
generate-matrix:
uses: pytorch/test-infra/.github/workflows/generate_binary_build_matrix.yml@main
with:
package-type: wheel
os: linux
test-infra-repository: pytorch/test-infra
test-infra-ref: main
with-cpu: disable
with-xpu: disable
with-cuda: disable
with-rocm: enable
build-python-only: "disable"
build:
needs: generate-matrix
strategy:
fail-fast: false
name: Build and Upload wheel
uses: pytorch/test-infra/.github/workflows/build_wheels_linux.yml@main
with:
repository: meta-pytorch/torchcodec
ref: ""
test-infra-repository: pytorch/test-infra
test-infra-ref: main
build-matrix: ${{ needs.generate-matrix.outputs.matrix }}
pre-script: packaging/pre_build_script.sh
post-script: packaging/post_build_script.sh
smoke-test-script: packaging/fake_smoke_test.py
package-name: torchcodec
trigger-event: ${{ github.event_name }}
build-platform: "python-build-package"
# ENABLE_ROCM=1 compiles the rocJPEG GPU JPEG decoder into
# libtorchcodec_image.so (the ROCm counterpart of nvJPEG). Video decoding
# stays on CPU. The FFmpeg core libs are still built against all FFmpeg.
build-command: "BUILD_AGAINST_ALL_FFMPEG_FROM_S3=1 ENABLE_ROCM=1 python -m build --wheel -vvv --no-isolation"
install-and-test:
# ROCm runners are not on EC2 and authenticate to AWS (ECR) via GitHub OIDC.
# Fork PRs don't get an OIDC id-token from GitHub, so the job can't pull the
# docker image and always fails. Skip it for fork PRs; it still runs on
# same-repo PRs, push, and workflow_dispatch.
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository
needs: build
strategy:
fail-fast: false
matrix:
python-version: ['3.10']
rocm-version: ['7.1']
ffmpeg-version-for-tests: ['7']
uses: pytorch/test-infra/.github/workflows/linux_job_v2.yml@main
permissions:
id-token: write
contents: read
with:
repository: meta-pytorch/torchcodec
runner: "linux.rocm.gpu.meta-pytorch.mi350.1"
gpu-arch-type: "rocm"
gpu-arch-version: ${{ matrix.rocm-version }}
# ROCm self-hosted runners are not on EC2, so they can't pull the default
# ECR-hosted docker image (no AWS credentials). Use a Docker Hub image and
# run without sudo, matching pytorch/vision's ROCm job.
docker-image: pytorch/manylinux2_28-builder:rocm${{ matrix.rocm-version }}
no-sudo: true
timeout: 120
test-infra-ref: main
download-artifact: meta-pytorch_torchcodec__${{ matrix.python-version }}_rocm${{ matrix.rocm-version }}_x86_64
script: |
set -euo pipefail
# The image's base conda uses the classic solver, which takes *hours* to
# solve conda-forge installs (ffmpeg's solve previously hit the 2h job
# timeout). Switch to libmamba, which solves in seconds. Install the
# plugin first in case this conda doesn't bundle it.
echo '::group::Configure conda (libmamba solver, conda-forge only)'
conda install -n base -y -c conda-forge conda-libmamba-solver
conda config --set solver libmamba
# Use conda-forge EXCLUSIVELY. Root cause of the 2h timeouts: the ffmpeg
# solve finished in minutes, but its dep tree resolves libglib & wayland
# from the 'defaults' (pkgs/main) channel, and downloading those from
# repo.anaconda.com hangs forever on the ROCm runners (no timeout).
# conda-forge egress works fine here (python/pip download in seconds), so
# we wipe the channel list down to conda-forge only so pkgs/main can
# never be selected.
conda config --remove-key channels 2>/dev/null || true
conda config --add channels conda-forge
conda config --set channel_priority strict
conda config --show channels
echo '::endgroup::'
# linux_job_v2 runs the script in the manylinux container's base conda
# env, whose Python isn't necessarily 3.10. The wheel is built cp310, so
# pip would reject it ("not a supported wheel on this platform"). Create
# and activate a matching Python env (conda is sourced by linux_job_v2).
echo '::group::Create Python ${{ matrix.python-version }} env'
conda create -y -n test -c conda-forge python=${{ matrix.python-version }} pip
conda activate test
python --version
echo '::endgroup::'
python -m pip install --upgrade pip
echo '::group::Install PyTorch (ROCm)'
pip install --progress-bar=off --pre torch \
--index-url https://download.pytorch.org/whl/nightly/rocm${{ matrix.rocm-version }}
echo '::endgroup::'
echo '::group::Assert we are on ROCm'
rocm-smi
python -c "
import torch
print('torch:', torch.__version__, '| hip:', torch.version.hip)
assert torch.version.hip is not None, 'torch is not a ROCm/HIP build'
assert torch.cuda.is_available(), 'no GPU visible to torch'
print('device:', torch.cuda.get_device_name(0))
"
echo '::endgroup::'
# Prevent the checked-out src/ tree from shadowing the installed wheel.
bash packaging/remove_src.sh
echo '::group::Install rocJPEG runtime'
# The wheel deliberately does not bundle librocjpeg (see repair_wheel.py),
# so decode_jpeg(device="cuda") needs it present at runtime.
bash packaging/install_rocjpeg.sh
echo '::endgroup::'
echo '::group::Install torchcodec from the wheel'
python -m pip install "${RUNNER_ARTIFACT_DIR}"/*.whl -vvv
echo '::endgroup::'
echo '::group::Install FFmpeg and test dependencies'
bash packaging/install_ffmpeg.sh ${{ matrix.ffmpeg-version-for-tests }}
# Pass false to skip the optional libheif conda install: HEIC is CPU-only,
# covered on other platforms, and not needed for this ROCm smoke test.
bash packaging/install_test_dependencies.sh false
echo '::endgroup::'
echo '::group::Run Python tests'
# torch.cuda.is_available() is True on ROCm (HIP masquerades as CUDA), so
# conftest.py won't auto-skip needs_cuda tests. The rocJPEG GPU decode
# path isn't validated yet (no ROCm-specific GPU tests), so we deselect
# them for now; drop this filter once rocJPEG decode is exercised.
FAIL_WITHOUT_JPEG=1 FAIL_WITHOUT_PNG=1 FAIL_WITHOUT_WEBP=1 FAIL_WITHOUT_AVIF=1 \
pytest -m "not needs_cuda" --override-ini="addopts=-v" test --tb=short
echo '::endgroup::'