Decode audio in the Blocks API, as RawAudioSamples #794
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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" | |
| python-versions: '["3.10", "3.11", "3.12", "3.13", "3.14"]' | |
| 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 | |
| # Via `bash` because vc_env_helper.bat runs the post-script in cmd. | |
| post-script: bash packaging/post_build_script.sh | |
| 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', '6', '7', '8', '9'] | |
| 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 | |
| uses: pytorch/test-infra/.github/actions/setup-nvidia-windows@main | |
| - 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::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" | |
| # FFmpeg 4 and 5 pin old aom/svt-av1 that conda's libheif can't satisfy; | |
| # here that surfaces as conda re-solving the CUDA packages against a | |
| # conda-forge-only channel set and failing to find cuda-cudart. HEIC is | |
| # CPU-only and still covered on the CUDA FFmpeg 6/7/8/9 jobs. | |
| - name: Install test dependencies | |
| run: bash -l packaging/install_test_dependencies.sh ${{ matrix.ffmpeg-version-for-tests != '4' && matrix.ffmpeg-version-for-tests != '5' }} | |
| - name: Run Python tests | |
| run: | | |
| if [ "${{ matrix.ffmpeg-version-for-tests }}" = "4" ] || [ "${{ matrix.ffmpeg-version-for-tests }}" = "5" ]; then export FAIL_WITHOUT_HEIC=0; fi | |
| python packaging/assert_ffmpeg_version.py ${{ matrix.ffmpeg-version-for-tests }} | |
| FAIL_WITHOUT_CUDA=1 FAIL_WITHOUT_IMAGE_CODECS=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 }} | |
| # -l exposes the conda CLI so the script can install libheif (the optional | |
| # HEIC runtime dep) for the HEIC smoke test. | |
| - name: Install test dependencies | |
| run: bash -l packaging/install_test_dependencies.sh ${{ env.FFMPEG_VERSION != '4' }} | |
| - name: Assert CUDA is not available | |
| run: | | |
| python -c "import torch; assert not torch.cuda.is_available()" | |
| - name: Run Python tests | |
| run: | | |
| if [ "${{ env.FFMPEG_VERSION }}" = "4" ]; then export FAIL_WITHOUT_HEIC=0; fi | |
| python packaging/assert_ffmpeg_version.py ${{ env.FFMPEG_VERSION }} | |
| FAIL_WITHOUT_IMAGE_CODECS=1 pytest --override-ini="addopts=-v" test/smoke_test.py --tb=short |