Skip to content

Commit

Permalink
[release/0.11] Add Python 3.10 (build and test) (#2255)
Browse files Browse the repository at this point in the history
Co-authored-by: Andrey Talman <atalman@fb.com>
  • Loading branch information
seemethere and atalman authored Feb 24, 2022
1 parent dc392e5 commit 820b383
Show file tree
Hide file tree
Showing 13 changed files with 1,053 additions and 124 deletions.
1,063 changes: 958 additions & 105 deletions .circleci/config.yml

Large diffs are not rendered by default.

12 changes: 11 additions & 1 deletion .circleci/config.yml.in
Original file line number Diff line number Diff line change
Expand Up @@ -459,6 +459,7 @@ jobs:
command: .circleci/unittest/linux/scripts/run_test.sh
environment:
TORCHAUDIO_TEST_ALLOW_SKIP_IF_NO_CUDA: true
TORCHAUDIO_TEST_ALLOW_SKIP_IF_ON_PYTHON_310: true
- store_test_results:
path: test-results
- store_artifacts:
Expand Down Expand Up @@ -488,7 +489,10 @@ jobs:
command: docker run -t --gpus all -e UPLOAD_CHANNEL -e CONDA_CHANNEL_FLAGS -v $PWD:$PWD -w $PWD "${image_name}" .circleci/unittest/linux/scripts/install.sh
- run:
name: Run tests
command: docker run -t --gpus all -v $PWD:$PWD -w $PWD -e "CI=${CI}" "${image_name}" .circleci/unittest/linux/scripts/run_test.sh
environment:
TORCHAUDIO_TEST_ALLOW_SKIP_IF_ON_PYTHON_310: true
command: |
docker run -t --gpus all -v $PWD:$PWD -w $PWD -e "CI=${CI}" -e TORCHAUDIO_TEST_ALLOW_SKIP_IF_ON_PYTHON_310 "${image_name}" .circleci/unittest/linux/scripts/run_test.sh
- store_test_results:
path: test-results
- store_artifacts:
Expand Down Expand Up @@ -522,6 +526,8 @@ jobs:
TORCHAUDIO_TEST_ALLOW_SKIP_IF_NO_CUDA: true
TORCHAUDIO_TEST_ALLOW_SKIP_IF_NO_KALDI: true
TORCHAUDIO_TEST_ALLOW_SKIP_IF_NO_SOX: true
TORCHAUDIO_TEST_ALLOW_SKIP_IF_ON_PYTHON_310: true
TORCHAUDIO_TEST_ALLOW_SKIP_IF_NO_MOD_sentencepiece: true
- store_test_results:
path: test-results
- store_artifacts:
Expand Down Expand Up @@ -563,6 +569,8 @@ jobs:
TORCHAUDIO_TEST_ALLOW_SKIP_IF_NO_CTC_DECODER: true
TORCHAUDIO_TEST_ALLOW_SKIP_IF_NO_KALDI: true
TORCHAUDIO_TEST_ALLOW_SKIP_IF_NO_SOX: true
TORCHAUDIO_TEST_ALLOW_SKIP_IF_ON_PYTHON_310: true
TORCHAUDIO_TEST_ALLOW_SKIP_IF_NO_MOD_sentencepiece: true
- store_test_results:
path: test-results
- store_artifacts:
Expand Down Expand Up @@ -596,6 +604,8 @@ jobs:
TORCHAUDIO_TEST_ALLOW_SKIP_IF_NO_CMD_COMPUTE_SPECTROGRAM_FEATS: true
TORCHAUDIO_TEST_ALLOW_SKIP_IF_NO_CUDA: true
TORCHAUDIO_TEST_ALLOW_SKIP_IF_NO_QUANTIZATION: true
TORCHAUDIO_TEST_ALLOW_SKIP_IF_ON_PYTHON_310: true
TORCHAUDIO_TEST_ALLOW_SKIP_IF_NO_MOD_sentencepiece: true
- store_test_results:
path: test-results
- store_artifacts:
Expand Down
2 changes: 1 addition & 1 deletion .circleci/regenerate.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
from jinja2 import select_autoescape


PYTHON_VERSIONS = ["3.7", "3.8", "3.9"]
PYTHON_VERSIONS = ["3.7", "3.8", "3.9", "3.10"]
CU_VERSIONS_DICT = {
"linux": ["cpu", "cu102", "cu111", "cu113", "cu115", "rocm4.3.1", "rocm4.5.2"],
"windows": ["cpu", "cu113", "cu115"],
Expand Down
8 changes: 6 additions & 2 deletions .circleci/unittest/linux/scripts/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,10 @@ fi

printf "Installing PyTorch with %s\n" "${cudatoolkit}"
(
if [[ "$(python --version)" = *3.10* ]]; then
CONDA_CHANNEL_FLAGS="-c conda-forge"
fi

if [ "${os}" == MacOSX ] ; then
# TODO: this can be removed as soon as linking issue could be resolved
# see https://github.com/pytorch/pytorch/issues/62424 from details
Expand All @@ -57,8 +61,8 @@ python setup.py install
# 3. Install Test tools
printf "* Installing test tools\n"
NUMBA_DEV_CHANNEL=""
if [[ "$(python --version)" = *3.9* ]]; then
# Numba isn't available for Python 3.9 except on the numba dev channel and building from source fails
if [[ "$(python --version)" = *3.9* || "$(python --version)" = *3.10* ]]; then
# Numba isn't available for Python 3.9 and 3.10 except on the numba dev channel and building from source fails
# See https://github.com/librosa/librosa/issues/1270#issuecomment-759065048
NUMBA_DEV_CHANNEL="-c numba/label/dev"
fi
Expand Down
10 changes: 9 additions & 1 deletion .circleci/unittest/linux/scripts/setup_env.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,15 @@ if [ ! -d "${conda_dir}" ]; then
bash ./miniconda.sh -b -f -p "${conda_dir}"
eval "$("${conda_dir}/bin/conda" shell.bash hook)"
printf "* Updating the base Python version to %s\n" "${PYTHON_VERSION}"
conda install --quiet -y python="${PYTHON_VERSION}"

ADDITIONAL_CHANNELS=""
if [[ ${PYTHON_VERSION} == 3.10 ]]; then
ADDITIONAL_CHANNELS="-c conda-forge"
fi

# Need to disable shell check since this'll fail out if ADDITIONAL_CHANNELS is empty
# shellcheck disable=SC2086
conda install ${ADDITIONAL_CHANNELS} --quiet -y python="${PYTHON_VERSION}"
else
eval "$("${conda_dir}/bin/conda" shell.bash hook)"
fi
Expand Down
35 changes: 29 additions & 6 deletions .circleci/unittest/windows/scripts/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -48,16 +48,39 @@ printf "* Installing torchaudio\n"
# 3. Install Test tools
printf "* Installing test tools\n"
NUMBA_DEV_CHANNEL=""
if [[ "$(python --version)" = *3.9* ]]; then
# Numba isn't available for Python 3.9 except on the numba dev channel and building from source fails
# See https://github.com/librosa/librosa/issues/1270#issuecomment-759065048
NUMBA_DEV_CHANNEL="-c numba/label/dev"
fi
SENTENCEPIECE_DEPENDENCY="sentencepiece"
case "$(python --version)" in
*3.9*)
# Numba isn't available for Python 3.9 except on the numba dev channel and building from source fails
# See https://github.com/librosa/librosa/issues/1270#issuecomment-759065048
NUMBA_DEV_CHANNEL="-c numba/label/dev"
;;
*3.10*)
# Don't install sentencepiece, no python 3.10 dependencies available for windows yet
SENTENCEPIECE_DEPENDENCY=""
NUMBA_DEV_CHANNEL="-c numba/label/dev"
;;
esac
# Note: installing librosa via pip fail because it will try to compile numba.
(
set -x
conda install -y -c conda-forge ${NUMBA_DEV_CHANNEL} 'librosa>=0.8.0' parameterized 'requests>=2.20'
pip install kaldi-io SoundFile coverage pytest pytest-cov scipy transformers expecttest unidecode inflect Pillow
# Need to disable shell check since this'll fail out if SENTENCEPIECE_DEPENDENCY is empty
# shellcheck disable=SC2086
pip install \
${SENTENCEPIECE_DEPENDENCY} \
Pillow \
SoundFile \
coverage \
expecttest \
inflect \
kaldi-io \
pytest \
pytest-cov \
pytorch-lightning \
scipy \
transformers \
unidecode
)
# Install fairseq
git clone https://github.com/pytorch/fairseq
Expand Down
10 changes: 9 additions & 1 deletion .circleci/unittest/windows/scripts/setup_env.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,15 @@ if [ ! -d "${conda_dir}" ]; then
unset miniconda_exe
eval "$("${conda_dir}/Scripts/conda.exe" 'shell.bash' 'hook')"
printf "* Updating the base Python version to %s\n" "${PYTHON_VERSION}"
conda install --quiet -y python="$PYTHON_VERSION"

ADDITIONAL_CHANNELS=""
if [[ ${PYTHON_VERSION} == 3.10 ]]; then
ADDITIONAL_CHANNELS="-c conda-forge"
fi

# Need to disable shell check since this'll fail out if ADDITIONAL_CHANNELS is empty
# shellcheck disable=SC2086
conda install ${ADDITIONAL_CHANNELS} --quiet -y python="$PYTHON_VERSION"
else
eval "$("${conda_dir}/Scripts/conda.exe" 'shell.bash' 'hook')"
fi
Expand Down
14 changes: 10 additions & 4 deletions packaging/build_conda.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,15 @@ setup_conda_cudatoolkit_constraint
setup_visual_studio_constraint

# nvidia channel included for cudatoolkit >= 11 however for 11.5 we use conda-forge
# HACK HACK HACK: Remove PYTHON_VERSION check once https://github.com/pytorch/builder/pull/961 is merged
export CUDATOOLKIT_CHANNEL="nvidia"
if [[ "$CU_VERSION" == cu115 ]]; then
export CUDATOOLKIT_CHANNEL="conda-forge"
# NOTE: This is needed because `cudatoolkit=11.5` has a dependency on conda-forge
# See: https://github.com/pytorch/audio/pull/2224#issuecomment-1049185550
if [[ ${CU_VERSION} = "cu115" ]]; then
CONDA_CHANNEL_FLAGS="${CONDA_CHANNEL_FLAGS} -c conda-forge"
fi

conda build -c defaults -c $CUDATOOLKIT_CHANNEL $CONDA_CHANNEL_FLAGS --no-anaconda-upload --python "$PYTHON_VERSION" packaging/torchaudio
# NOTE: There are some dependencies that are not available for macOS on Python 3.10 without conda-forge
if [[ ${OSTYPE} =~ darwin* ]] && [[ ${PYTHON_VERSION} = "3.10" ]]; then
CONDA_CHANNEL_FLAGS="${CONDA_CHANNEL_FLAGS} -c conda-forge"
fi
conda build -c defaults -c $CUDATOOLKIT_CHANNEL ${CONDA_CHANNEL_FLAGS:-} --no-anaconda-upload --python "$PYTHON_VERSION" packaging/torchaudio
1 change: 1 addition & 0 deletions packaging/pkg_helpers.bash
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,7 @@ setup_wheel_python() {
3.7) python_abi=cp37-cp37m ;;
3.8) python_abi=cp38-cp38 ;;
3.9) python_abi=cp39-cp39 ;;
3.10) python_abi=cp310-cp310 ;;
*)
echo "Unrecognized PYTHON_VERSION=$PYTHON_VERSION"
exit 1
Expand Down
6 changes: 4 additions & 2 deletions packaging/torchaudio/meta.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,17 @@ requirements:
- pkg-config # [not win]
- cmake
- ninja
- defaults::numpy >=1.11
- numpy>=1.11 # [py <= 39]
- numpy>=1.21.2 # [py >= 310]
- pytorch-mutex 1.0 {{ build_variant }} # [not osx ]
{{ environ.get('CONDA_PYTORCH_BUILD_CONSTRAINT', 'pytorch') }}
{{ environ.get('CONDA_EXTRA_BUILD_CONSTRAINT', '') }}
{{ environ.get('CONDA_CUDATOOLKIT_CONSTRAINT', '') }}

run:
- python
- defaults::numpy >=1.11
- numpy>=1.11 # [py <= 39]
- numpy>=1.21.2 # [py >= 310]
- pytorch-mutex 1.0 {{ build_variant }} # [not osx ]
{{ environ.get('CONDA_PYTORCH_CONSTRAINT', 'pytorch') }}
{{ environ.get('CONDA_CUDATOOLKIT_CONSTRAINT', '') }}
Expand Down
2 changes: 2 additions & 0 deletions test/torchaudio_unittest/common_utils/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
skipIfRocm,
skipIfNoQengine,
skipIfNoFFmpeg,
skipIfPy310,
)
from .data_utils import (
get_asset_path,
Expand Down Expand Up @@ -59,6 +60,7 @@
"skipIfRocm",
"skipIfNoQengine",
"skipIfNoFFmpeg",
"skipIfPy310",
"get_wav_data",
"normalize_wav",
"load_wav",
Expand Down
9 changes: 9 additions & 0 deletions test/torchaudio_unittest/common_utils/case_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import os.path
import shutil
import subprocess
import sys
import tempfile
import time
import unittest
Expand Down Expand Up @@ -212,3 +213,11 @@ def skipIfNoModule(module, display_name=None):
reason="ffmpeg features are not available.",
key="NO_FFMPEG",
)
skipIfPy310 = _skipIf(
sys.version_info >= (3, 10, 0),
reason=(
"Test is known to fail for Python 3.10, disabling for now"
"See: https://github.com/pytorch/audio/pull/2224#issuecomment-1048329450"
),
key="ON_PYTHON_310",
)
5 changes: 4 additions & 1 deletion test/torchaudio_unittest/models/tacotron2/model_test_impl.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from torch import Tensor
from torchaudio.models import Tacotron2
from torchaudio.models.tacotron2 import _Encoder, _Decoder
from torchaudio_unittest.common_utils import TestBaseMixin, torch_script
from torchaudio_unittest.common_utils import TestBaseMixin, torch_script, skipIfPy310


class Tacotron2InferenceWrapper(torch.nn.Module):
Expand Down Expand Up @@ -42,6 +42,7 @@ def _assert_torchscript_consistency(self, model, tensors):


class Tacotron2EncoderTests(TorchscriptConsistencyMixin):
@skipIfPy310
def test_tacotron2_torchscript_consistency(self):
r"""Validate the torchscript consistency of a Encoder."""
n_batch, n_seq, encoder_embedding_dim = 16, 64, 512
Expand Down Expand Up @@ -265,6 +266,7 @@ def _get_inputs(self, n_mels: int, n_batch: int, max_mel_specgram_length: int, m
(16,),
]
)
@skipIfPy310
def test_tacotron2_torchscript_consistency(self, n_batch):
r"""Validate the torchscript consistency of a Tacotron2."""
n_mels = 80
Expand Down Expand Up @@ -333,6 +335,7 @@ def _get_inference_inputs(self, n_batch: int, max_text_length: int):
(16,),
]
)
@skipIfPy310
def test_tacotron2_inference_torchscript_consistency(self, n_batch):
r"""Validate the torchscript consistency of Tacotron2 inference function."""
n_mels = 40
Expand Down

0 comments on commit 820b383

Please sign in to comment.