Commit 27dff6ba authored by Andrey Talman's avatar Andrey Talman Committed by Facebook GitHub Bot
Browse files

Add Python 3.10 (build and test) (#2224)

Summary:
Adding py3.10 to audio

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

Reviewed By: malfet, atalman, mthrok

Differential Revision: D34442377

Pulled By: seemethere

fbshipit-source-id: 2656de73427063958d609a74c01b526a476cb06a
parent 1fb10077
This diff is collapsed.
...@@ -475,6 +475,7 @@ jobs: ...@@ -475,6 +475,7 @@ jobs:
command: .circleci/unittest/linux/scripts/run_test.sh command: .circleci/unittest/linux/scripts/run_test.sh
environment: environment:
TORCHAUDIO_TEST_ALLOW_SKIP_IF_NO_CUDA: true TORCHAUDIO_TEST_ALLOW_SKIP_IF_NO_CUDA: true
TORCHAUDIO_TEST_ALLOW_SKIP_IF_ON_PYTHON_310: true
- store_test_results: - store_test_results:
path: test-results path: test-results
- store_artifacts: - store_artifacts:
...@@ -504,7 +505,10 @@ jobs: ...@@ -504,7 +505,10 @@ jobs:
command: docker run -t --gpus all -e UPLOAD_CHANNEL -e CONDA_CHANNEL_FLAGS -e BUILD_FFMPEG=1 -v $PWD:$PWD -w $PWD "${image_name}" .circleci/unittest/linux/scripts/install.sh command: docker run -t --gpus all -e UPLOAD_CHANNEL -e CONDA_CHANNEL_FLAGS -e BUILD_FFMPEG=1 -v $PWD:$PWD -w $PWD "${image_name}" .circleci/unittest/linux/scripts/install.sh
- run: - run:
name: Run tests 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: - store_test_results:
path: test-results path: test-results
- store_artifacts: - store_artifacts:
...@@ -540,6 +544,8 @@ jobs: ...@@ -540,6 +544,8 @@ jobs:
TORCHAUDIO_TEST_ALLOW_SKIP_IF_NO_CUDA: true TORCHAUDIO_TEST_ALLOW_SKIP_IF_NO_CUDA: true
TORCHAUDIO_TEST_ALLOW_SKIP_IF_NO_KALDI: true TORCHAUDIO_TEST_ALLOW_SKIP_IF_NO_KALDI: true
TORCHAUDIO_TEST_ALLOW_SKIP_IF_NO_SOX: 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: - store_test_results:
path: test-results path: test-results
- store_artifacts: - store_artifacts:
...@@ -583,6 +589,8 @@ jobs: ...@@ -583,6 +589,8 @@ jobs:
TORCHAUDIO_TEST_ALLOW_SKIP_IF_NO_CTC_DECODER: true TORCHAUDIO_TEST_ALLOW_SKIP_IF_NO_CTC_DECODER: true
TORCHAUDIO_TEST_ALLOW_SKIP_IF_NO_KALDI: true TORCHAUDIO_TEST_ALLOW_SKIP_IF_NO_KALDI: true
TORCHAUDIO_TEST_ALLOW_SKIP_IF_NO_SOX: 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: - store_test_results:
path: test-results path: test-results
- store_artifacts: - store_artifacts:
...@@ -618,6 +626,8 @@ jobs: ...@@ -618,6 +626,8 @@ jobs:
TORCHAUDIO_TEST_ALLOW_SKIP_IF_NO_CMD_COMPUTE_SPECTROGRAM_FEATS: true 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_CUDA: true
TORCHAUDIO_TEST_ALLOW_SKIP_IF_NO_QUANTIZATION: 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: - store_test_results:
path: test-results path: test-results
- store_artifacts: - store_artifacts:
......
...@@ -21,7 +21,7 @@ import yaml ...@@ -21,7 +21,7 @@ import yaml
from jinja2 import select_autoescape 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 = { CU_VERSIONS_DICT = {
"linux": ["cpu", "cu102", "cu111", "cu113", "cu115", "rocm4.3.1", "rocm4.5.2"], "linux": ["cpu", "cu102", "cu111", "cu113", "cu115", "rocm4.3.1", "rocm4.5.2"],
"windows": ["cpu", "cu113", "cu115"], "windows": ["cpu", "cu113", "cu115"],
......
...@@ -37,6 +37,10 @@ fi ...@@ -37,6 +37,10 @@ fi
printf "Installing PyTorch with %s\n" "${cudatoolkit}" printf "Installing PyTorch with %s\n" "${cudatoolkit}"
( (
if [[ "$(python --version)" = *3.10* ]]; then
CONDA_CHANNEL_FLAGS="-c conda-forge"
fi
if [ "${os}" == MacOSX ] ; then if [ "${os}" == MacOSX ] ; then
# TODO: this can be removed as soon as linking issue could be resolved # TODO: this can be removed as soon as linking issue could be resolved
# see https://github.com/pytorch/pytorch/issues/62424 from details # see https://github.com/pytorch/pytorch/issues/62424 from details
...@@ -57,8 +61,8 @@ python setup.py install ...@@ -57,8 +61,8 @@ python setup.py install
# 3. Install Test tools # 3. Install Test tools
printf "* Installing test tools\n" printf "* Installing test tools\n"
NUMBA_DEV_CHANNEL="" NUMBA_DEV_CHANNEL=""
if [[ "$(python --version)" = *3.9* ]]; then if [[ "$(python --version)" = *3.9* || "$(python --version)" = *3.10* ]]; then
# Numba isn't available for Python 3.9 except on the numba dev channel and building from source fails # 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 # See https://github.com/librosa/librosa/issues/1270#issuecomment-759065048
NUMBA_DEV_CHANNEL="-c numba/label/dev" NUMBA_DEV_CHANNEL="-c numba/label/dev"
fi fi
......
...@@ -25,7 +25,15 @@ if [ ! -d "${conda_dir}" ]; then ...@@ -25,7 +25,15 @@ if [ ! -d "${conda_dir}" ]; then
bash ./miniconda.sh -b -f -p "${conda_dir}" bash ./miniconda.sh -b -f -p "${conda_dir}"
eval "$("${conda_dir}/bin/conda" shell.bash hook)" eval "$("${conda_dir}/bin/conda" shell.bash hook)"
printf "* Updating the base Python version to %s\n" "${PYTHON_VERSION}" 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 else
eval "$("${conda_dir}/bin/conda" shell.bash hook)" eval "$("${conda_dir}/bin/conda" shell.bash hook)"
fi fi
......
...@@ -48,16 +48,39 @@ printf "* Installing torchaudio\n" ...@@ -48,16 +48,39 @@ printf "* Installing torchaudio\n"
# 3. Install Test tools # 3. Install Test tools
printf "* Installing test tools\n" printf "* Installing test tools\n"
NUMBA_DEV_CHANNEL="" NUMBA_DEV_CHANNEL=""
if [[ "$(python --version)" = *3.9* ]]; then SENTENCEPIECE_DEPENDENCY="sentencepiece"
# Numba isn't available for Python 3.9 except on the numba dev channel and building from source fails case "$(python --version)" in
# See https://github.com/librosa/librosa/issues/1270#issuecomment-759065048 *3.9*)
NUMBA_DEV_CHANNEL="-c numba/label/dev" # Numba isn't available for Python 3.9 except on the numba dev channel and building from source fails
fi # 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. # Note: installing librosa via pip fail because it will try to compile numba.
( (
set -x set -x
conda install -y -c conda-forge ${NUMBA_DEV_CHANNEL} 'librosa>=0.8.0' parameterized 'requests>=2.20' 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 sentencepiece pytorch-lightning # 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 # Install fairseq
git clone https://github.com/pytorch/fairseq git clone https://github.com/pytorch/fairseq
......
...@@ -25,7 +25,15 @@ if [ ! -d "${conda_dir}" ]; then ...@@ -25,7 +25,15 @@ if [ ! -d "${conda_dir}" ]; then
unset miniconda_exe unset miniconda_exe
eval "$("${conda_dir}/Scripts/conda.exe" 'shell.bash' 'hook')" eval "$("${conda_dir}/Scripts/conda.exe" 'shell.bash' 'hook')"
printf "* Updating the base Python version to %s\n" "${PYTHON_VERSION}" 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 else
eval "$("${conda_dir}/Scripts/conda.exe" 'shell.bash' 'hook')" eval "$("${conda_dir}/Scripts/conda.exe" 'shell.bash' 'hook')"
fi fi
......
...@@ -12,9 +12,15 @@ setup_conda_cudatoolkit_constraint ...@@ -12,9 +12,15 @@ setup_conda_cudatoolkit_constraint
setup_visual_studio_constraint setup_visual_studio_constraint
# nvidia channel included for cudatoolkit >= 11 however for 11.5 we use conda-forge # 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" export CUDATOOLKIT_CHANNEL="nvidia"
if [[ "$CU_VERSION" == cu115 ]]; then # NOTE: This is needed because `cudatoolkit=11.5` has a dependency on conda-forge
export CUDATOOLKIT_CHANNEL="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 fi
# NOTE: There are some dependencies that are not available for macOS on Python 3.10 without conda-forge
conda build -c defaults -c $CUDATOOLKIT_CHANNEL $CONDA_CHANNEL_FLAGS --no-anaconda-upload --python "$PYTHON_VERSION" packaging/torchaudio 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
...@@ -197,6 +197,7 @@ setup_wheel_python() { ...@@ -197,6 +197,7 @@ setup_wheel_python() {
3.7) python_abi=cp37-cp37m ;; 3.7) python_abi=cp37-cp37m ;;
3.8) python_abi=cp38-cp38 ;; 3.8) python_abi=cp38-cp38 ;;
3.9) python_abi=cp39-cp39 ;; 3.9) python_abi=cp39-cp39 ;;
3.10) python_abi=cp310-cp310 ;;
*) *)
echo "Unrecognized PYTHON_VERSION=$PYTHON_VERSION" echo "Unrecognized PYTHON_VERSION=$PYTHON_VERSION"
exit 1 exit 1
......
...@@ -17,7 +17,8 @@ requirements: ...@@ -17,7 +17,8 @@ requirements:
- pkg-config # [not win] - pkg-config # [not win]
- cmake - cmake
- ninja - ninja
- defaults::numpy >=1.11 - numpy>=1.11 # [py <= 39]
- numpy>=1.21.2 # [py >= 310]
- pytorch-mutex 1.0 {{ build_variant }} # [not osx ] - pytorch-mutex 1.0 {{ build_variant }} # [not osx ]
{{ environ.get('CONDA_PYTORCH_BUILD_CONSTRAINT', 'pytorch') }} {{ environ.get('CONDA_PYTORCH_BUILD_CONSTRAINT', 'pytorch') }}
{{ environ.get('CONDA_EXTRA_BUILD_CONSTRAINT', '') }} {{ environ.get('CONDA_EXTRA_BUILD_CONSTRAINT', '') }}
...@@ -26,7 +27,8 @@ requirements: ...@@ -26,7 +27,8 @@ requirements:
run: run:
- python - python
- defaults::numpy >=1.11 - numpy>=1.11 # [py <= 39]
- numpy>=1.21.2 # [py >= 310]
- pytorch-mutex 1.0 {{ build_variant }} # [not osx ] - pytorch-mutex 1.0 {{ build_variant }} # [not osx ]
{{ environ.get('CONDA_PYTORCH_CONSTRAINT', 'pytorch') }} {{ environ.get('CONDA_PYTORCH_CONSTRAINT', 'pytorch') }}
{{ environ.get('CONDA_CUDATOOLKIT_CONSTRAINT', '') }} {{ environ.get('CONDA_CUDATOOLKIT_CONSTRAINT', '') }}
......
...@@ -17,6 +17,7 @@ from .case_utils import ( ...@@ -17,6 +17,7 @@ from .case_utils import (
skipIfRocm, skipIfRocm,
skipIfNoQengine, skipIfNoQengine,
skipIfNoFFmpeg, skipIfNoFFmpeg,
skipIfPy310,
) )
from .data_utils import ( from .data_utils import (
get_asset_path, get_asset_path,
...@@ -59,6 +60,7 @@ __all__ = [ ...@@ -59,6 +60,7 @@ __all__ = [
"skipIfRocm", "skipIfRocm",
"skipIfNoQengine", "skipIfNoQengine",
"skipIfNoFFmpeg", "skipIfNoFFmpeg",
"skipIfPy310",
"get_wav_data", "get_wav_data",
"normalize_wav", "normalize_wav",
"load_wav", "load_wav",
......
...@@ -2,6 +2,7 @@ import functools ...@@ -2,6 +2,7 @@ import functools
import os.path import os.path
import shutil import shutil
import subprocess import subprocess
import sys
import tempfile import tempfile
import time import time
import unittest import unittest
...@@ -212,3 +213,11 @@ skipIfNoFFmpeg = _skipIf( ...@@ -212,3 +213,11 @@ skipIfNoFFmpeg = _skipIf(
reason="ffmpeg features are not available.", reason="ffmpeg features are not available.",
key="NO_FFMPEG", 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,7 +5,7 @@ from parameterized import parameterized ...@@ -5,7 +5,7 @@ from parameterized import parameterized
from torch import Tensor from torch import Tensor
from torchaudio.models import Tacotron2 from torchaudio.models import Tacotron2
from torchaudio.models.tacotron2 import _Encoder, _Decoder 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): class Tacotron2InferenceWrapper(torch.nn.Module):
...@@ -42,6 +42,7 @@ class TorchscriptConsistencyMixin(TestBaseMixin): ...@@ -42,6 +42,7 @@ class TorchscriptConsistencyMixin(TestBaseMixin):
class Tacotron2EncoderTests(TorchscriptConsistencyMixin): class Tacotron2EncoderTests(TorchscriptConsistencyMixin):
@skipIfPy310
def test_tacotron2_torchscript_consistency(self): def test_tacotron2_torchscript_consistency(self):
r"""Validate the torchscript consistency of a Encoder.""" r"""Validate the torchscript consistency of a Encoder."""
n_batch, n_seq, encoder_embedding_dim = 16, 64, 512 n_batch, n_seq, encoder_embedding_dim = 16, 64, 512
...@@ -265,6 +266,7 @@ class Tacotron2Tests(TorchscriptConsistencyMixin): ...@@ -265,6 +266,7 @@ class Tacotron2Tests(TorchscriptConsistencyMixin):
(16,), (16,),
] ]
) )
@skipIfPy310
def test_tacotron2_torchscript_consistency(self, n_batch): def test_tacotron2_torchscript_consistency(self, n_batch):
r"""Validate the torchscript consistency of a Tacotron2.""" r"""Validate the torchscript consistency of a Tacotron2."""
n_mels = 80 n_mels = 80
...@@ -333,6 +335,7 @@ class Tacotron2Tests(TorchscriptConsistencyMixin): ...@@ -333,6 +335,7 @@ class Tacotron2Tests(TorchscriptConsistencyMixin):
(16,), (16,),
] ]
) )
@skipIfPy310
def test_tacotron2_inference_torchscript_consistency(self, n_batch): def test_tacotron2_inference_torchscript_consistency(self, n_batch):
r"""Validate the torchscript consistency of Tacotron2 inference function.""" r"""Validate the torchscript consistency of Tacotron2 inference function."""
n_mels = 40 n_mels = 40
......
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