install.sh 2.94 KB
Newer Older
1
2
3
4
5
6
7
#!/usr/bin/env bash

unset PYTORCH_VERSION
# For unittest, nightly PyTorch is used as the following section,
# so no need to set PYTORCH_VERSION.
# In fact, keeping PYTORCH_VERSION forces us to hardcode PyTorch version in config.

8
set -ex
9

moto's avatar
moto committed
10
11
12
root_dir="$(git rev-parse --show-toplevel)"
conda_dir="${root_dir}/conda"
env_dir="${root_dir}/env"
13
this_dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
14

moto's avatar
moto committed
15
16
17
18
19
20
cd "${root_dir}"

# 0. Activate conda env
eval "$("${conda_dir}/Scripts/conda.exe" 'shell.bash' 'hook')"
conda activate "${env_dir}"

21
22
source "$this_dir/set_cuda_envs.sh"

moto's avatar
moto committed
23
# 1. Install PyTorch
24
25
if [ -z "${CUDA_VERSION:-}" ] ; then
    cudatoolkit="cpuonly"
26
    version="cpu"
27
28
else
    version="$(python -c "print('.'.join(\"${CUDA_VERSION}\".split('.')[:2]))")"
29
30
31
32
33
34
35

    cuda_toolkit_pckg="cudatoolkit"
    if [[ "$CU_VERSION" == cu116 ]]; then
        cuda_toolkit_pckg="cuda"
    fi

    cudatoolkit="${cuda_toolkit_pckg}=${version}"
36
37
fi
printf "Installing PyTorch with %s\n" "${cudatoolkit}"
moto's avatar
moto committed
38
conda install -y -c "pytorch-${UPLOAD_CHANNEL}" -c conda-forge "pytorch-${UPLOAD_CHANNEL}"::pytorch[build="*${version}*"] "${cudatoolkit}" 'mkl=2020.4' pytest
39
40
41
42
43
44
45
46
47
48

torch_cuda=$(python -c "import torch; print(torch.cuda.is_available())")
echo torch.cuda.is_available is $torch_cuda

if [ ! -z "${CUDA_VERSION:-}" ] ; then
    if [ "$torch_cuda" == "False" ]; then
        echo "torch with cuda installed but torch.cuda.is_available() is False"
        exit 1
    fi
fi
49

moto's avatar
moto committed
50
# 2. Install torchaudio
51
printf "* Installing torchaudio\n"
52
"$root_dir/packaging/vc_env_helper.bat" python setup.py install
moto's avatar
moto committed
53
54
55

# 3. Install Test tools
printf "* Installing test tools\n"
Eli Uriegas's avatar
Eli Uriegas committed
56
NUMBA_DEV_CHANNEL=""
57
58
59
60
61
62
63
64
65
66
67
68
69
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
Eli Uriegas's avatar
Eli Uriegas committed
70
71
72
73
# 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'
74
75
76
77
78
79
80
81
82
83
84
85
86
    # 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 \
moto's avatar
moto committed
87
        'scipy==1.7.3' \
88
        transformers \
moto's avatar
moto committed
89
        unidecode \
90
        'protobuf<4.21.0' \
moto's avatar
moto committed
91
92
        demucs \
        tinytag
Eli Uriegas's avatar
Eli Uriegas committed
93
)
moto's avatar
moto committed
94
95
96
# Install fairseq
git clone https://github.com/pytorch/fairseq
cd fairseq
97
git checkout e47a4c8
moto's avatar
moto committed
98
pip install .