Commit 0db5ab25 authored by moto's avatar moto Committed by Facebook GitHub Bot
Browse files

Build and use GPU-enabled FFmpeg in doc CI (#3045)

Summary:
This commit add the step to build FFmpeg with GPU decoder in build_doc job so that we can use GPU decoder/encoder in documentations.

Pull Request resolved: https://github.com/pytorch/audio/pull/3045

Reviewed By: nateanl

Differential Revision: D45965739

Pulled By: mthrok

fbshipit-source-id: c167eb3ef347860a51efa906068fa2daa556f017
parent 72d3fe09
...@@ -37,6 +37,8 @@ jobs: ...@@ -37,6 +37,8 @@ jobs:
export PYTHON_VERSION="${{ matrix.python_version }}" export PYTHON_VERSION="${{ matrix.python_version }}"
export CU_VERSION="${{ matrix.cuda_arch_version }}" export CU_VERSION="${{ matrix.cuda_arch_version }}"
export CUDATOOLKIT="pytorch-cuda=${CU_VERSION}" export CUDATOOLKIT="pytorch-cuda=${CU_VERSION}"
export CODEC_HEADER_VERSION=n11.1.5.2
export COMPUTE_CAPABILITY=86
# Set CHANNEL # Set CHANNEL
if [[(${GITHUB_EVENT_NAME} = 'pull_request' && (${GITHUB_BASE_REF} = 'release'*)) || (${GITHUB_REF} = 'refs/heads/release'*) ]]; then if [[(${GITHUB_EVENT_NAME} = 'pull_request' && (${GITHUB_BASE_REF} = 'release'*)) || (${GITHUB_REF} = 'refs/heads/release'*) ]]; then
...@@ -49,6 +51,50 @@ jobs: ...@@ -49,6 +51,50 @@ jobs:
conda create --quiet -y --prefix ci_env python="${PYTHON_VERSION}" conda create --quiet -y --prefix ci_env python="${PYTHON_VERSION}"
conda activate ./ci_env conda activate ./ci_env
# Install FFmpeg-dependencies
conda install --quiet -y -c conda-forge yasm x264 gnutls pkg-config lame libopus libvpx openh264 openssl x264
# Build FFmpeg with NVIDIA Video Codec SDK
# TODO cache this
(
git clone --quiet https://git.videolan.org/git/ffmpeg/nv-codec-headers.git
cd nv-codec-headers
git checkout ${CODEC_HEADER_VERSION}
make PREFIX=${CONDA_PREFIX} install
)
(
wget -q https://github.com/FFmpeg/FFmpeg/archive/refs/tags/n5.1.3.tar.gz
tar -xf n5.1.3.tar.gz
cd ./FFmpeg-n5.1.3
export revision=5.1.3
./configure \
--prefix=${CONDA_PREFIX} \
--extra-cflags="-I${CONDA_PREFIX}/include" \
--extra-ldflags="-L${CONDA_PREFIX}/lib" \
--nvccflags="-gencode arch=compute_${COMPUTE_CAPABILITY},code=sm_${COMPUTE_CAPABILITY} -O2" \
--disable-doc \
--enable-rpath \
--disable-static \
--enable-protocol=https \
--enable-gnutls \
--enable-shared \
--enable-gpl \
--enable-nonfree \
--enable-libmp3lame \
--enable-libx264 \
--enable-cuda-nvcc \
--enable-nvenc \
--enable-cuvid \
--enable-nvdec
make clean
make -j > /dev/null 2>&1
make install
# test
src="https://download.pytorch.org/torchaudio/tutorial-assets/stream-api/NASAs_Most_Scientifically_Complex_Space_Observatory_Requires_Precision-MP4_small.mp4"
ffmpeg -y -vsync 0 -hwaccel cuvid -hwaccel_output_format cuda -c:v h264_cuvid -resize 360x240 -i "${src}" -c:a copy -c:v h264_nvenc -b:v 5M test.mp4
)
# Install PyTorch # Install PyTorch
set -ex set -ex
set +u # don't know why set +u # don't know why
...@@ -60,14 +106,12 @@ jobs: ...@@ -60,14 +106,12 @@ jobs:
"${CUDATOOLKIT}" "${CUDATOOLKIT}"
# Install torchaudio # Install torchaudio
# TODO: Enable NVDec/NVEnc
conda install --quiet -y -c conda-forge 'ffmpeg>=5.0,<6' pkg-config
pip --quiet install cmake>=3.18.0 ninja pip --quiet install cmake>=3.18.0 ninja
cd packaging cd packaging
. ./pkg_helpers.bash . ./pkg_helpers.bash
setup_build_version setup_build_version
cd ../ cd ../
USE_FFMPEG=1 pip install --progress-bar off -v -e . --no-use-pep517 FFMPEG_ROOT=${CONDA_PREFIX} USE_FFMPEG=1 USE_CUDA=1 pip install --progress-bar off -v -e . --no-use-pep517
# Install runtime dependencies # Install runtime dependencies
pip --quiet install git+https://github.com/kpu/kenlm/ flashlight-text pip --quiet install git+https://github.com/kpu/kenlm/ flashlight-text
......
...@@ -44,7 +44,6 @@ model implementations and application components. ...@@ -44,7 +44,6 @@ model implementations and application components.
tutorials/streamreader_advanced_tutorial tutorials/streamreader_advanced_tutorial
tutorials/streamwriter_basic_tutorial tutorials/streamwriter_basic_tutorial
tutorials/streamwriter_advanced tutorials/streamwriter_advanced
hw_acceleration_tutorial
tutorials/effector_tutorial tutorials/effector_tutorial
tutorials/audio_resampling_tutorial tutorials/audio_resampling_tutorial
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment