Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use pre-built binaries for ffmpeg extension #3460

Closed
wants to merge 1 commit into from

Conversation

mthrok
Copy link
Collaborator

@mthrok mthrok commented Jul 6, 2023

This commit changes the way FFmpeg extension is built.

Originally, the build process expected the FFmpeg binaries to be somehow available in build env.
This makes the build process unpredictable and prevents default enabling FFmpeg extension.

The proposed change uses pre-built FFmpeg binaries as build-time only scaffold, which are built in our CI job https://github.com/pytorch/audio/actions/workflows/ffmpeg.yml.

This makes the build process more predictable and removes the necessity to build FFmpeg in our CI.
Currently, it supports macOS (arm64, x86_64), unix (x86_64, aarch64) and windows (amd64).
The downside is that it no longer works with the architecture not listed above.
We can potentially workaround by searching the FFmpeg binaries available in system (the old way) for
these system, but since they are not supported by PyTorch, the priority is low.

@pytorch-bot
Copy link

pytorch-bot bot commented Jul 6, 2023

🔗 Helpful Links

🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/audio/3460

Note: Links to docs will display an error until the docs builds have been completed.

❌ 4 New Failures, 1 Unrelated Failure

As of commit 505780b:

NEW FAILURES - The following jobs have failed:

BROKEN TRUNK - The following job failed but were present on the merge base d9f51ce:

👉 Rebase onto the `viable/strict` branch to avoid these failures

This comment was automatically generated by Dr. CI and updates every 15 minutes.

@mthrok mthrok force-pushed the prebuilt-ffmpeg branch 3 times, most recently from cfa76f8 to d835de6 Compare July 6, 2023 12:36
@facebook-github-bot
Copy link
Contributor

@mthrok has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

@mthrok mthrok force-pushed the prebuilt-ffmpeg branch 5 times, most recently from 083f072 to a369cc4 Compare July 7, 2023 13:20
@mthrok mthrok marked this pull request as ready for review July 7, 2023 13:41
@facebook-github-bot
Copy link
Contributor

@mthrok has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

@facebook-github-bot
Copy link
Contributor

@mthrok merged this pull request in f77c3e5.

@github-actions
Copy link

github-actions bot commented Jul 7, 2023

Hey @mthrok.
You merged this PR, but labels were not properly added. Please add a primary and secondary label (See https://github.com/pytorch/audio/blob/main/.github/process_commit.py).


Some guidance:

Use 'module: ops' for operations under 'torchaudio/{transforms, functional}', and ML-related components under 'torchaudio/csrc' (e.g. RNN-T loss).

Things in "examples" directory:

  • 'recipe' is applicable to training recipes under the 'examples' folder,
  • 'tutorial' is applicable to tutorials under the “examples/tutorials” folder
  • 'example' is applicable to everything else (e.g. C++ examples)
  • 'module: docs' is applicable to code documentations (not to tutorials).

Regarding examples in code documentations, please also use 'module: docs'.

Please use 'other' tag only when you’re sure the changes are not much relevant to users, or when all other tags are not applicable. Try not to use it often, in order to minimize efforts required when we prepare release notes.


When preparing release notes, please make sure 'documentation' and 'tutorials' occur as the last sub-categories under each primary category like 'new feature', 'improvements' or 'prototype'.

Things related to build are by default excluded from the release note, except when it impacts users. For example:
* Drop support of Python 3.7.
* Add support of Python 3.X.
* Change the way a third party library is bound (so that user needs to install it separately).

@mthrok mthrok deleted the prebuilt-ffmpeg branch July 7, 2023 17:50
mthrok added a commit to pytorch/test-infra that referenced this pull request Jul 7, 2023
pytorch/audio#3460 changed the way torchaudio is built,
and there is no longer need to supply FFmepg externally.
test-infra no longer needs to build FFmpeg and use pre/post-scripts for torchaudio.

The only issue remaining for now is smoke test.
Currently torchaudio's smoke test script by default expects that FFmpeg libraries
are available. This can be disabled with `--no-ffmpeg`, but the way YML files are
written in test-infra repo does not allow to pass a flag to smoke test.

We can switch the behavior, or use other smoke test.
mthrok added a commit to pytorch/test-infra that referenced this pull request Jul 10, 2023
pytorch/audio#3460 changed the way torchaudio is built,
and there is no longer need to supply FFmepg externally.
test-infra no longer needs to build FFmpeg and use pre/post-scripts for torchaudio.

The only issue remaining for now is smoke test.
Currently torchaudio's smoke test script by default expects that FFmpeg libraries
are available. This can be disabled with `--no-ffmpeg`, but the way YML files are
written in test-infra repo does not allow to pass a flag to smoke test.

We can switch the behavior, or use other smoke test.
atalman pushed a commit to pytorch/test-infra that referenced this pull request Jul 11, 2023
This commit removes all the code related to FFmpeg, which are specific
to torchaudio.

pytorch/audio#3460 changed the way torchaudio is
built. FFmpeg integration is handled automatically and enabled by
default. This eliminates the need to supply FFmepg externally.
test-infra no longer needs to build FFmpeg and use pre/post-scripts for
torchaudio.

Note that smoke test was updated in
pytorch/audio#3465 to not use FFmpeg for wheel.
We will revisit this later with multiple FFmpeg version support.
facebook-github-bot pushed a commit that referenced this pull request Aug 15, 2023
Summary:
In #3460, we switched the build process for FFmpeg extension.
Since it is complicated to install FFmpeg in some environments, at build time, pre-built binaries and its headers
are downloaded and used as a scaffolding for torchaudio build.

Now even though we did not change any code or FFmpeg version, it turned out that this causes segmentation
fault on Ubuntu when using system Python and FFmpeg 4.4 installed via aptitude.
While investigating the issue, I swapped the said pre-built FFmpeg scaffolding with FFmpeg 4.4 from aptitude,
and the segmentation fault did not happen. This indicates that it is binary compatibility issue.

Before #3460, each binary build job was building FFmpeg 4.1.8 using the same compiler used to build torchaudio,
but after #3460 the environments to build FFmpeg 4.1.8 and torchaudio are different. My hypothesis is that
this difference is causing some ABI incompatibility when linking against FFmpeg 4.4. (Also, I don't remember well,
but I read somewhere that 4.4 has a different ABI)

Through experiments, it turned out upgrading the pre-built FFmpeg scaffolding to 4.4 resolves this.
So this commit upgrade the pre-built FFmpeg 4 to 4.4.
The potential (yet unconfirmed) downside is that torchaudio will no longer work with 4.1, 4.2, and 4.3.
Since FFmpeg 4.4 is what Ubuntu 20.04 and 22.04 support by default, and Google Colab is also on 20.04,
I think it is more important to support 4.4.

Therefore we drop the support for 4.1-4.3 from normal build (and official distributions). Those who wish to
use 4.1-4.3 can build torchaudio from source by linking to specific FFmpeg.

Pull Request resolved: #3561

Reviewed By: hwangjeff

Differential Revision: D48340201

Pulled By: mthrok

fbshipit-source-id: 7ece82910f290c7cf83f58311c4cf6a384e8795e
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants