Skip to content

Commit

Permalink
Merge branch 'main' of github.com:pytorch/torchcodec into benchmark_test
Browse files Browse the repository at this point in the history
  • Loading branch information
scotts committed Nov 13, 2024
2 parents 6cc503c + bd9d5cb commit 64c4a79
Show file tree
Hide file tree
Showing 15 changed files with 452 additions and 103 deletions.
1 change: 1 addition & 0 deletions .github/workflows/build_ffmpeg.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ on:
pull_request:
paths:
- packaging/build_ffmpeg.sh
- .github/workflows/build_ffmpeg.yaml # self reference
schedule:
- cron: '0 0 * * 0' # on sunday

Expand Down
4 changes: 4 additions & 0 deletions .github/workflows/cpp_tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ on:
push:
branches: [ main ]
pull_request:
paths:
- src/torchcodec/*
- test/*
- .github/workflows/cpp_tests.yaml # self reference

concurrency:
group: unit-test${{ github.workflow }}-${{ github.ref == 'refs/heads/main' && github.run_number || github.ref }}
Expand Down
110 changes: 90 additions & 20 deletions .github/workflows/docs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,46 +4,116 @@ on:
push:
branches: [ main ]
pull_request:
paths:
- src/torchcodec/*
- docs/*
- .github/workflows/docs.yaml # self reference

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: linux
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:
runs-on: ubuntu-latest
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: pytorch/torchcodec
ref: ""
test-infra-repository: pytorch/test-infra
test-infra-ref: main
build-matrix: ${{ needs.generate-matrix.outputs.matrix }}
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"
build-command: "BUILD_AGAINST_ALL_FFMPEG_FROM_S3=1 ENABLE_CUDA=1 python -m build --wheel -vvv --no-isolation"

build-docs:
runs-on: linux.4xlarge.nvidia.gpu
strategy:
fail-fast: false
matrix:
# 3.9 corresponds to the minimum python version for which we build
# the wheel unless the label cliflow/binaries/all is present in the
# PR.
python-version: ['3.9']
cuda-version: ['12.4']
ffmpeg-version-for-tests: ['7']
container:
image: "pytorch/manylinux-builder:cuda${{ matrix.cuda-version }}"
options: "--gpus all -e NVIDIA_DRIVER_CAPABILITIES=video,compute,utility"
needs: build
steps:
- name: Check out repo
uses: actions/checkout@v3
- name: Setup conda env
uses: conda-incubator/setup-miniconda@v2
- 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
- uses: actions/download-artifact@v3
with:
auto-update-conda: true
miniconda-version: "latest"
activate-environment: test
python-version: '3.12'
name: pytorch_torchcodec__3.9_cu${{ env.cuda_version_without_periods }}_x86_64
path: pytorch/torchcodec/dist/
- name: Setup miniconda using test-infra
uses: pytorch/test-infra/.github/actions/setup-miniconda@main
with:
python-version: ${{ matrix.python-version }}
#
# For some reason nvidia::libnpp=12.4 doesn't install but nvidia/label/cuda-12.4.0::libnpp does.
# So we use the latter convention for libnpp.
# We install conda packages at the start because otherwise conda may have conflicts with dependencies.
default-packages: "nvidia/label/cuda-${{ matrix.cuda-version }}.0::libnpp nvidia::cuda-nvrtc=${{ matrix.cuda-version }} nvidia::cuda-toolkit=${{ matrix.cuda-version }} nvidia::cuda-cudart=${{ matrix.cuda-version }} nvidia::cuda-driver-dev=${{ matrix.cuda-version }} conda-forge::ffmpeg=${{ matrix.ffmpeg-version-for-tests }}"
- name: Check env
run: |
${CONDA_RUN} env
${CONDA_RUN} conda info
${CONDA_RUN} nvidia-smi
${CONDA_RUN} conda list
- name: Assert ffmpeg exists
run: |
${CONDA_RUN} ffmpeg -buildconf
- name: Update pip
run: python -m pip install --upgrade pip
- name: Install dependencies and FFmpeg
run: ${CONDA_RUN} python -m pip install --upgrade pip
- name: Install PyTorch
run: |
# TODO: torchvision and torchaudio shouldn't be needed. They were only added
# to silence an error as seen in https://github.com/pytorch/torchcodec/issues/203
python -m pip install --pre torch torchvision torchaudio --index-url https://download.pytorch.org/whl/nightly/cpu
conda install "ffmpeg=7.0.1" pkg-config -c conda-forge
ffmpeg -version
- name: Build and install torchcodec
${CONDA_RUN} python -m pip install --pre torch torchvision --index-url https://download.pytorch.org/whl/nightly/cu${{ env.cuda_version_without_periods }}
${CONDA_RUN} python -c 'import torch; print(f"{torch.__version__}"); print(f"{torch.__file__}"); print(f"{torch.cuda.is_available()=}")'
- name: Install torchcodec from the wheel
run: |
python -m pip install -e ".[dev]" --no-build-isolation -vvv
wheel_path=`find pytorch/torchcodec/dist -type f -name "*.whl"`
echo Installing $wheel_path
${CONDA_RUN} python -m pip install $wheel_path -vvv
- name: Check out repo
uses: actions/checkout@v3

- name: Install doc dependencies
run: |
cd docs
python -m pip install -r requirements.txt
${CONDA_RUN} python -m pip install -r requirements.txt
- name: Build docs
run: |
cd docs
make html
${CONDA_RUN} make html
- uses: actions/upload-artifact@v3
with:
name: Built-Docs
Expand Down
6 changes: 6 additions & 0 deletions .github/workflows/linux_cuda_wheel.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@ name: Build and test Linux CUDA wheels

on:
pull_request:
paths:
- src/torchcodec/*
- benchmarks/*
- packaging/*
- test/*
- .github/workflows/linux_cuda_wheel.yaml # self reference
push:
branches:
- nightly
Expand Down
5 changes: 5 additions & 0 deletions .github/workflows/linux_wheel.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@ name: Build and test Linux wheel

on:
pull_request:
paths:
- src/torchcodec/*
- packaging/*
- test/*
- .github/workflows/linux_wheel.yaml # self reference
push:
branches:
- nightly
Expand Down
5 changes: 5 additions & 0 deletions .github/workflows/macos_wheel.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@ name: Build and test MacOS wheel

on:
pull_request:
paths:
- src/torchcodec/*
- packaging/*
- test/*
- .github/workflows/macos_wheel.yaml # self reference
push:
branches:
- nightly
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/reference_resources.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ on:
pull_request:
paths:
- test/generate_reference_resources.sh
- .github/workflows/reference_resources.yaml # self reference
schedule:
- cron: '0 0 * * 0' # on sunday

Expand Down
49 changes: 27 additions & 22 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -94,29 +94,38 @@ ffmpeg -f lavfi -i \

## Installing TorchCodec

Note: if you're on MacOS, you'll need to [build from source](./CONTRIBUTING.md).
The instructions below assume you're on Linux.
1. Install the latest stable version of PyTorch following the
[official instructions](https://pytorch.org/get-started/locally/). For other
versions, refer to the table below for compatibility between versions of
`torch` and `torchcodec`.

1. Install the latest stable version of PyTorch following the
[official instructions](https://pytorch.org/get-started/locally/). TorchCodec
requires [PyTorch 2.4](https://pytorch.org/docs/2.4/).
2. Install FFmpeg, if it's not already installed. Linux distributions usually
come with FFmpeg pre-installed. TorchCodec supports all major FFmpeg versions
in [4, 7].

2. Install FFmpeg, if it's not already installed. Your Linux distribution probably
comes with FFmpeg pre-installed. TorchCodec supports all major FFmpeg versions
in [4, 7].
If FFmpeg is not already installed, or you need a more recent version, an
easy way to install it is to use `conda`:

If FFmpeg is not already installed, or you need a later version, install it with:
```bash
conda install ffmpeg
# or
conda install ffmpeg -c conda-forge
```

```bash
conda install ffmpeg
# or
conda install ffmpeg -c conda-forge
```
3. Install TorchCodec:
3. Install TorchCodec:

```bash
pip install torchcodec
```
```bash
pip install torchcodec
```

The following table indicates the compatibility between versions of
`torchcodec`, `torch` and Python.

| `torchcodec` | `torch` | Python |
| ------------------ | ------------------ | ------------------- |
| `main` / `nightly` | `main` / `nightly` | `>=3.9`, `<=3.12` |
| not yet supported | `2.5` | `>=3.9`, `<=3.12` |
| `0.0.3` | `2.4` | `>=3.8`, `<=3.12` |

## Benchmark Results

Expand All @@ -134,10 +143,6 @@ encoded with libx264 and yuv420p pixel format.

We are actively working on the following features:

- [Ship wheels for MacOS](https://github.com/pytorch/torchcodec/issues/111), so
that MacOS users can `pip install torchcodec`. For now this is only supported
on Linux, but MacOS users can [build from source](./CONTRIBUTING.md).
- [GPU decoding](https://github.com/pytorch/torchcodec/pull/58)
- [Audio decoding](https://github.com/pytorch/torchcodec/issues/85)

Let us know if you have any feature requests by [opening an
Expand Down
2 changes: 2 additions & 0 deletions benchmarks/decoders/benchmark_decoders.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

from benchmark_decoders_library import (
AbstractDecoder,
BatchParameters,
DecordAccurate,
DecordAccurateBatch,
plot_data,
Expand Down Expand Up @@ -173,6 +174,7 @@ def main() -> None:
num_sequential_frames_from_start=[1, 10, 100],
min_runtime_seconds=args.bm_video_speed_min_run_seconds,
benchmark_video_creation=args.bm_video_creation,
batch_parameters=BatchParameters(num_threads=8, batch_size=40),
)
plot_data(df_data, args.plot_path)

Expand Down
Loading

0 comments on commit 64c4a79

Please sign in to comment.