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

Run GPU video decoder/encoder tests in CI (#3490)

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

Differential Revision: D47757316

Pulled By: mthrok

fbshipit-source-id: cfb376be29980f9e452f291c4fa25780e9f85a97
parent 135cb7ba
#!/usr/bin/env bash
# This script builds FFmpeg with NVIDIA Video codec SDK support.
#
# IMPORTANT:
# The resulting library files are non-distributable.
# Do not ship them. Do not use them for binary build.
set -eux
revision="${FFMPEG_VERSION:-6.0}"
codec_header_version="${CODEC_HEADER_VERSION:-n12.0.16.0}"
prefix="${PREFIX:-${CONDA_PREFIX}}"
ccap="${COMPUTE_CAPABILITY:-86}"
# 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=${prefix} install
)
conda install \
--quiet --yes \
-c conda-forge \
yasm x264 gnutls pkg-config lame libopus libvpx openh264 openssl x264
(
wget -q https://github.com/FFmpeg/FFmpeg/archive/refs/tags/n${revision}.tar.gz
tar -xf n${revision}.tar.gz
cd ./FFmpeg-n${revision}
# Sometimes, the resulting FFmpeg binaries have development version number.
# Setting `revision` variable ensures that it has the right version number.
export revision=${revision}
./configure \
--prefix="${prefix}" \
--extra-cflags="-I${prefix}/include" \
--extra-ldflags="-L${prefix}/lib" \
--nvccflags="-gencode arch=compute_${ccap},code=sm_${ccap} -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
)
...@@ -30,16 +30,11 @@ jobs: ...@@ -30,16 +30,11 @@ jobs:
upload-artifact: docs upload-artifact: docs
script: | script: |
# Mark Build Directory Safe set -ex
git config --global --add safe.directory /__w/audio/audio
# Set up Environment Variables # Set up Environment Variables
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 FFMPEG_VERSION=6.0
export CODEC_HEADER_VERSION=n12.0.16.0
export COMPUTE_CAPABILITY=86
export BUILD_VERSION="$( cut -f 1 -d a version.txt )".dev"$(date "+%Y%m%d")" export BUILD_VERSION="$( cut -f 1 -d a version.txt )".dev"$(date "+%Y%m%d")"
# Set CHANNEL # Set CHANNEL
...@@ -49,13 +44,14 @@ jobs: ...@@ -49,13 +44,14 @@ jobs:
export CHANNEL=nightly export CHANNEL=nightly
fi fi
# Create Conda Env echo "::group::Create conda env"
# Mark Build Directory Safe
git config --global --add safe.directory /__w/audio/audio
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 PyTorch / TorchAudio first echo "::endgroup::"
set -ex echo "::group::Install PyTorch"
set +u # don't know why
conda install \ conda install \
--yes \ --yes \
--quiet \ --quiet \
...@@ -63,65 +59,32 @@ jobs: ...@@ -63,65 +59,32 @@ jobs:
-c nvidia "pytorch-${CHANNEL}"::pytorch[build="*${CU_VERSION}*"] \ -c nvidia "pytorch-${CHANNEL}"::pytorch[build="*${CU_VERSION}*"] \
"${CUDATOOLKIT}" "${CUDATOOLKIT}"
# Install torchaudio echo "::endgroup::"
echo "::group::Install TorchAudio"
conda install --quiet --yes pkg-config cmake>=3.18.0 ninja conda install --quiet --yes pkg-config cmake>=3.18.0 ninja
pip install --progress-bar off -v -e . --no-use-pep517 pip3 install --progress-bar off -v -e . --no-use-pep517
# Install FFmpeg-dependencies
conda install --quiet --yes -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
)
( echo "::endgroup::"
wget -q https://github.com/FFmpeg/FFmpeg/archive/refs/tags/n${FFMPEG_VERSION}.tar.gz echo "::group::Build FFmpeg"
tar -xf n${FFMPEG_VERSION}.tar.gz .github/scripts/ffmpeg/build_gpu.sh
cd ./FFmpeg-n${FFMPEG_VERSION}
export revision=${FFMPEG_VERSION}
./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 runtime dependencies echo "::endgroup::"
pip --quiet install git+https://github.com/kpu/kenlm/ flashlight-text echo "::group::Install other dependencies"
conda install \
# Install build tools --quiet --yes \
conda install --quiet -y -c conda-forge pandoc doxygen pysoundfile -c conda-forge \
pip install --quiet -r docs/requirements.txt -r docs/requirements-tutorials.txt pandoc doxygen pysoundfile
pip install --progress-bar off \
# Build docs git+https://github.com/kpu/kenlm/ flashlight-text \
-r docs/requirements.txt -r docs/requirements-tutorials.txt
echo "::endgroup::"
echo "::group::Build documentation"
export BUILD_GALLERY=true export BUILD_GALLERY=true
(cd docs && make html) (cd docs && make html)
echo "::endgroup::"
echo "::group::Copy artifact"
cp -rf docs/build/html/* "${RUNNER_DOCS_DIR}" cp -rf docs/build/html/* "${RUNNER_DOCS_DIR}"
mv docs/build/html /artifacts/ mv docs/build/html /artifacts/
......
...@@ -25,13 +25,19 @@ jobs: ...@@ -25,13 +25,19 @@ jobs:
timeout: 120 timeout: 120
script: | script: |
# Mark Build Directory Safe set -ex
git config --global --add safe.directory /__w/audio/audio
# Set up Environment Variables # Set up Environment Variables
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 TORCHAUDIO_TEST_ALLOW_SKIP_IF_NO_CMD_APPLY_CMVN_SLIDING=true
export TORCHAUDIO_TEST_ALLOW_SKIP_IF_NO_CMD_COMPUTE_FBANK_FEATS=true
export TORCHAUDIO_TEST_ALLOW_SKIP_IF_NO_CMD_COMPUTE_KALDI_PITCH_FEATS=true
export TORCHAUDIO_TEST_ALLOW_SKIP_IF_NO_CMD_COMPUTE_MFCC_FEATS=true
export TORCHAUDIO_TEST_ALLOW_SKIP_IF_NO_CMD_COMPUTE_SPECTROGRAM_FEATS=true
export TORCHAUDIO_TEST_ALLOW_SKIP_IF_CUDA_SMALL_MEMORY=true
export TORCHAUDIO_TEST_ALLOW_SKIP_IF_ON_PYTHON_310=true
export TORCHAUDIO_TEST_ALLOW_SKIP_IF_TEMPORARY_DISABLED=true
# 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
...@@ -40,13 +46,14 @@ jobs: ...@@ -40,13 +46,14 @@ jobs:
export CHANNEL=nightly export CHANNEL=nightly
fi fi
# Create Conda Env echo "::group::Create conda env"
# Mark Build Directory Safe
git config --global --add safe.directory /__w/audio/audio
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 PyTorch echo "::endgroup::"
set -ex echo "::group::Install PyTorch"
set +u # don't know why
conda install \ conda install \
--yes \ --yes \
--quiet \ --quiet \
...@@ -54,26 +61,46 @@ jobs: ...@@ -54,26 +61,46 @@ jobs:
-c nvidia "pytorch-${CHANNEL}"::pytorch[build="*${CU_VERSION}*"] \ -c nvidia "pytorch-${CHANNEL}"::pytorch[build="*${CU_VERSION}*"] \
"${CUDATOOLKIT}" "${CUDATOOLKIT}"
# Install torchaudio echo "::endgroup::"
conda install --quiet -y pkg-config 'cmake>=3.18.0' ninja echo "::group::Install TorchAudio"
python3 -m pip install -v -e . --no-use-pep517 conda install --quiet --yes pkg-config 'cmake>=3.18.0' ninja
pip3 install --progress-bar off -v -e . --no-use-pep517
echo "::endgroup::"
echo "::group::Build FFmpeg"
.github/scripts/ffmpeg/build_gpu.sh
# Install test tools echo "::endgroup::"
conda install -y --quiet -c conda-forge -c numba/label/dev 'librosa==0.10.0' parameterized 'requests>=2.20' 'ffmpeg>=5,<7' echo "::group::Install other Dependencies"
python3 -m pip install --quiet kaldi-io SoundFile coverage pytest pytest-cov 'scipy==1.7.3' transformers expecttest unidecode inflect Pillow sentencepiece pytorch-lightning 'protobuf<4.21.0' demucs tinytag flashlight-text git+https://github.com/kpu/kenlm/ conda install \
python3 -m pip install --quiet git+https://github.com/pytorch/fairseq.git@e47a4c8 --quiet --yes \
-c conda-forge \
-c numba/label/dev \
'librosa==0.10.0' parameterized 'requests>=2.20'
pip3 install --progress-bar off \
kaldi-io \
SoundFile \
coverage \
pytest \
pytest-cov \
'scipy==1.7.3' \
transformers \
expecttest \
unidecode \
inflect \
Pillow \
sentencepiece \
pytorch-lightning \
'protobuf<4.21.0' \
demucs \
tinytag \
flashlight-text \
git+https://github.com/kpu/kenlm/ \
git+https://github.com/pytorch/fairseq.git@e47a4c8
# Run tests echo "::endgroup::"
echo "::group::Run tests"
export PATH="${PWD}/third_party/install/bin/:${PATH}" export PATH="${PWD}/third_party/install/bin/:${PATH}"
export TORCHAUDIO_TEST_ALLOW_SKIP_IF_NO_CMD_APPLY_CMVN_SLIDING=true
export TORCHAUDIO_TEST_ALLOW_SKIP_IF_NO_CMD_COMPUTE_FBANK_FEATS=true
export TORCHAUDIO_TEST_ALLOW_SKIP_IF_NO_CMD_COMPUTE_KALDI_PITCH_FEATS=true
export TORCHAUDIO_TEST_ALLOW_SKIP_IF_NO_CMD_COMPUTE_MFCC_FEATS=true
export TORCHAUDIO_TEST_ALLOW_SKIP_IF_NO_CMD_COMPUTE_SPECTROGRAM_FEATS=true
export TORCHAUDIO_TEST_ALLOW_SKIP_IF_CUDA_SMALL_MEMORY=true
export TORCHAUDIO_TEST_ALLOW_SKIP_IF_NO_HW_ACCEL=true
export TORCHAUDIO_TEST_ALLOW_SKIP_IF_ON_PYTHON_310=true
export TORCHAUDIO_TEST_ALLOW_SKIP_IF_TEMPORARY_DISABLED=true
declare -a args=( declare -a args=(
'-v' '-v'
......
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