Skip to content

Recommended way to conda install pytorch, torchaudio, and ffmpeg without conflicts #3269

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

Closed
Barker404 opened this issue Apr 17, 2023 · 5 comments
Labels

Comments

@Barker404
Copy link

I would like to build a linux-64 conda environment containing the following:

  • pytorch
  • torchaudio
  • ffmpeg at a recent version (I actually use ffmpeg via pyav, so it must be a recent version to allow using a recent python version)

The following approach results in a conflict:

$ CONDA_SUBDIR=linux-64 CONDA_CHANNEL_PRIORITY=strict conda create --name test -c pytorch -c conda-forge pytorch torchaudio 'ffmpeg>5'
[...]
LibMambaUnsatisfiableError: Encountered problems while solving:
  - package ffmpeg-5.1.2-lgpl_hd27bd3a_6 is excluded by strict repo priority

Because an old version of ffmpeg is available in the pytorch channel, so strict channel priority (recommended by conda https://docs.conda.io/projects/conda/en/latest/user-guide/tasks/manage-channels.html#strict-channel-priority) prevents using a lower priority channel.

torchaudio is not available in conda-forge so I need both channels. If I make the conda-forge channel higher priority than the pytorch channel then I end up with pytorch and torchaudio from different channels, which causes errors at runtime.

It seems like the only way to achieve this is to use flexible channel priority rather than strict, but conda discourage this and plan to make strict the default in future. Do you have any recommendations?

@hwangjeff
Copy link
Contributor

To avoid the conflict, can you install ffmpeg separately with the channel overridden, after creating the conda environment? Also note that the officially distributed TorchAudio binaries are not compatible with ffmpeg>5 — if compatibility is a requirement, please build TorchAudio from source (https://pytorch.org/audio/main/installation.html#optional-dependencies).

@Barker404
Copy link
Author

Installing ffmpeg afterwards isn't great for me, as then I can't define my conda requirements in a single file (I'm using conda-lock for this).

Thanks for the heads up about ffmpeg compatibility. I hadn't actually been aware that ffmpeg was an optional dependency of torchaudio, I'm using pyav separately and not using torchaudio.io so hopefully that won't be a problem.

It sounds like for now flexible channel priority might be the best option for me.

@mthrok
Copy link
Collaborator

mthrok commented Apr 25, 2023

TorchAudio supporting FFmpeg5 is one thing I am planning to address, but the dual use of PyAV makes the thing complicated.

I doubt that installing separate FFmpeg would help. PyAV uses its own FFmpeg, therefore if you try to load another FFmpeg libraries after importing PyAV, I think the application will crash due to the duplicated symbols from FFmpeg. Therefore I do not think it is really a solution to install torchaudio with supported FFmepg alongside PyAV. I think one way to work around is to build torchaudio by linking against the FFmpeg bundled with PyAV.

@mthrok mthrok added the triaged label Apr 25, 2023
@mthrok
Copy link
Collaborator

mthrok commented May 17, 2023

We have updated the ffmpeg version to 5 in nightly build. Hopefully it will resolve in the next release.
But we cannot guarantee the compatibility with ffmpeg shipped with PyAV.

@mthrok mthrok closed this as completed May 17, 2023
@Barker404
Copy link
Author

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants