How to make torchaudio select the customized compiled ffmpeg

I installed pytorch using miniconda by

conda install pytorch torchvision torchaudio pytorch-cuda=11.8 -c pytorch -c nvidia

Now I want to use the GPU video decoder/encoder of torchaudio.

I compiled and installed a ffmpeg with cuda support following the guide in Enabling GPU video decoder/encoder — Torchaudio 2.0.1 documentation (

However, after installation, torchaudio cannot pick the correct ffmpeg outside miniconda since ffmpeg is installed by conda as a dependency while installing pytorch.

How can I fix this problem?

You might need to build torchaudio from source and let it pick your custom library during the build.

Ended up with compiling and installing everything (includingffmpeg and cuda) from source into conda env. torchaudio does not need re-compilation and it picks the correct ffmpeg then.