forked from meta-pytorch/torchcodec
-
Notifications
You must be signed in to change notification settings - Fork 0
215 lines (187 loc) · 7.89 KB
/
Copy pathwindows_cuda_wheel.yaml
File metadata and controls
215 lines (187 loc) · 7.89 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
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
name: Windows CUDA
on:
pull_request:
push:
branches:
- nightly
- main
- release/*
tags:
- v[0-9]+.[0-9]+.[0-9]+-rc[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: write
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: windows
test-infra-repository: pytorch/test-infra
test-infra-ref: main
with-cpu: disable
with-xpu: disable
with-rocm: disable
with-cuda: 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_windows.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 TODO: consider enabling post-build checks for Windows
env-script: packaging/vc_env_helper.bat
smoke-test-script: packaging/fake_smoke_test.py
package-name: torchcodec
trigger-event: ${{ github.event_name }}
build-platform: "python-build-package"
# The BUILD_AGAINST_ALL_FFMPEG_FROM_S3 and ENABLE_CUDA vars, needed to
# build the wheel, are set in vc_env_helper.bat. Couldn't find a way to
# set them from here.
build-command: "python -m build --wheel -vvv --no-isolation"
install-and-test:
runs-on: windows.g5.4xlarge.nvidia.gpu
strategy:
fail-fast: false
matrix:
# 3.10 corresponds to the minimum python version for which we build
# the wheel unless the label cliflow/binaries/all is present in the
# PR.
# For the actual release we should add that label and change this to
# include more python versions.
python-version: ['3.10']
cuda-version: ['12.6', '13.0']
# TODO: FFmpeg 5 on Windows segfaults in avcodec_open2() when passing
# bad parameters.
# See https://github.com/pytorch/torchcodec/pull/806
ffmpeg-version-for-tests: ['4.4.2', '6.1.1', '7.0.1', '8.0']
needs: build
steps:
- name: Setup env vars
run: |
cuda_version_without_periods=$(echo "${{ matrix.cuda-version }}" | sed 's/\.//g')
echo cuda_version_without_periods=${cuda_version_without_periods} >> $GITHUB_ENV
python_version_without_periods=$(echo "${{ matrix.python-version }}" | sed 's/\.//g')
echo python_version_without_periods=${python_version_without_periods} >> $GITHUB_ENV
- name: Check out repo
uses: actions/checkout@v6
- name: Update NVIDIA driver
shell: cmd
run: |
curl --retry 3 -kL https://ossci-windows.s3.amazonaws.com/580.88-data-center-tesla-desktop-win10-win11-64bit-dch-international.exe --output driver_installer.exe
start /wait driver_installer.exe -s -noreboot
del driver_installer.exe
nvidia-smi
- name: Remove src/ folder
run: bash packaging/remove_src.sh
- name: Setup conda env
uses: conda-incubator/setup-miniconda@v3
with:
auto-update-conda: true
miniforge-version: latest
activate-environment: test
python-version: ${{ matrix.python-version }}
- name: Install CUDA and FFmpeg conda packages
run: |
conda install -y \
"nvidia/label/cuda-${{ matrix.cuda-version }}.0::libnpp" \
"nvidia::cuda-nvrtc=${{ matrix.cuda-version }}" \
"nvidia::cuda-cudart=${{ matrix.cuda-version }}" \
"conda-forge::ffmpeg=${{ matrix.ffmpeg-version-for-tests }}"
- name: Check env
run: |
env
conda info
conda list
- name: Assert ffmpeg exists
run: |
ffmpeg -buildconf
- name: Check FFmpeg CUDA support
run: |
ffmpeg -decoders | grep -i nvidia
- name: Update pip
run: python -m pip install --upgrade pip
- name: Install PyTorch
run: |
bash packaging/install_pytorch.sh cu${{ env.cuda_version_without_periods }} "torch torchvision"
python -c 'import torch; print(f"{torch.__version__}"); print(f"{torch.__file__}"); print(f"{torch.cuda.is_available()=}")'
- uses: actions/download-artifact@v4
with:
name: meta-pytorch_torchcodec__${{ matrix.python-version }}_cu${{ env.cuda_version_without_periods }}_x64
path: dist/
- name: Install torchcodec from the wheel
run: bash packaging/install_torchcodec_wheel.sh "*cu${{ env.cuda_version_without_periods }}-cp${{ env.python_version_without_periods }}*.whl"
- name: Install test dependencies
run: bash packaging/install_test_dependencies.sh
- name: Run Python tests
run: |
FAIL_WITHOUT_CUDA=1 pytest --override-ini="addopts=-v" test/smoke_test.py --tb=short
- name: Run Python benchmark
run: |
time python benchmarks/decoders/gpu_benchmark.py --devices=cuda:0,cpu --resize_devices=none
install-and-test-on-cpu-only-machine:
# This job tests that CUDA wheels work fine on CPU-only machines. Note that
# we still install a CUDA-enabled version of torch, and that's by design.
# Essentially, what we want to make sure is that
# `pip install torch torchcodec` works on CPU-only machines, and this
# command should install CUDA-enabled versions of both torch and torchcodec.
# It's critical that this job runs on a CPU-only machine.
runs-on: windows-latest
needs: build
env:
PYTHON_VERSION: '3.10'
CUDA_VERSION: '12.6'
FFMPEG_VERSION: '7'
steps:
- name: Setup env vars
run: |
cuda_version_without_periods=$(echo "${{ env.CUDA_VERSION }}" | sed 's/\.//g')
echo cuda_version_without_periods=${cuda_version_without_periods} >> $GITHUB_ENV
python_version_without_periods=$(echo "${{ env.PYTHON_VERSION }}" | sed 's/\.//g')
echo python_version_without_periods=${python_version_without_periods} >> $GITHUB_ENV
- name: Check out repo
uses: actions/checkout@v6
- name: Remove src/ folder
run: bash packaging/remove_src.sh
- name: Setup conda env
uses: conda-incubator/setup-miniconda@v3
with:
auto-update-conda: true
miniforge-version: latest
activate-environment: test
python-version: ${{ env.PYTHON_VERSION }}
- name: Update pip
run: python -m pip install --upgrade pip
- name: Install PyTorch
run: bash packaging/install_pytorch.sh cu${{ env.cuda_version_without_periods }} "torch torchvision"
- uses: actions/download-artifact@v4
with:
name: meta-pytorch_torchcodec__${{ env.PYTHON_VERSION }}_cu${{ env.cuda_version_without_periods }}_x64
path: dist/
- name: Install torchcodec from the wheel
run: bash packaging/install_torchcodec_wheel.sh "*cu${{ env.cuda_version_without_periods }}-cp${{ env.python_version_without_periods }}*.whl"
- name: Install ffmpeg
run: bash -l packaging/install_ffmpeg.sh ${{ env.FFMPEG_VERSION }}
- name: Install test dependencies
run: bash packaging/install_test_dependencies.sh
- name: Assert CUDA is not available
run: |
python -c "import torch; assert not torch.cuda.is_available()"
- name: Run Python tests
run: |
pytest --override-ini="addopts=-v" test/smoke_test.py --tb=short