Skip to content

Commit

Permalink
Build and use GPU-enabled FFmpeg in doc CI (#3045)
Browse files Browse the repository at this point in the history
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: #3045

Reviewed By: nateanl

Differential Revision: D45965739

Pulled By: mthrok

fbshipit-source-id: c167eb3ef347860a51efa906068fa2daa556f017
  • Loading branch information
mthrok authored and facebook-github-bot committed May 19, 2023
1 parent 72d3fe0 commit 0db5ab2
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 4 deletions.
50 changes: 47 additions & 3 deletions .github/workflows/build_docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ jobs:
export PYTHON_VERSION="${{ matrix.python_version }}"
export CU_VERSION="${{ matrix.cuda_arch_version }}"
export CUDATOOLKIT="pytorch-cuda=${CU_VERSION}"
export CODEC_HEADER_VERSION=n11.1.5.2
export COMPUTE_CAPABILITY=86
# Set CHANNEL
if [[(${GITHUB_EVENT_NAME} = 'pull_request' && (${GITHUB_BASE_REF} = 'release'*)) || (${GITHUB_REF} = 'refs/heads/release'*) ]]; then
Expand All @@ -49,6 +51,50 @@ jobs:
conda create --quiet -y --prefix ci_env python="${PYTHON_VERSION}"
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
set -ex
set +u # don't know why
Expand All @@ -60,14 +106,12 @@ jobs:
"${CUDATOOLKIT}"
# 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
cd packaging
. ./pkg_helpers.bash
setup_build_version
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
pip --quiet install git+https://github.com/kpu/kenlm/ flashlight-text
Expand Down
1 change: 0 additions & 1 deletion docs/source/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ model implementations and application components.
tutorials/streamreader_advanced_tutorial
tutorials/streamwriter_basic_tutorial
tutorials/streamwriter_advanced
hw_acceleration_tutorial

tutorials/effector_tutorial
tutorials/audio_resampling_tutorial
Expand Down

0 comments on commit 0db5ab2

Please sign in to comment.