install.sh 2.56 KB
Newer Older
1
2
3
4
5
6
7
8
9
#!/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.

set -e

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

moto's avatar
moto committed
14
15
16
17
18
19
20
21
22
23
24
25
cd "${root_dir}"

case "$(uname -s)" in
    Darwin*) os=MacOSX;;
    *) os=Linux
esac

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

# 1. Install PyTorch
moto's avatar
moto committed
26
27
28
29
30
31
if [ -z "${CUDA_VERSION:-}" ] ; then
    if [ "${os}" == MacOSX ] ; then
        cudatoolkit=''
    else
        cudatoolkit="cpuonly"
    fi
32
    version="cpu"
moto's avatar
moto committed
33
else
moto's avatar
moto committed
34
    version="$(python -c "print('.'.join(\"${CUDA_VERSION}\".split('.')[:2]))")"
35
    export CUDATOOLKIT_CHANNEL="nvidia"
atalman's avatar
atalman committed
36
    cudatoolkit="pytorch-cuda=${version}"
moto's avatar
moto committed
37
fi
38

moto's avatar
moto committed
39
printf "Installing PyTorch with %s\n" "${cudatoolkit}"
40
(
Nikita Shulga's avatar
Nikita Shulga committed
41
42
43
44
    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
      MKL_CONSTRAINT='mkl==2021.2.0'
45
      pytorch_build=pytorch
Nikita Shulga's avatar
Nikita Shulga committed
46
47
    else
      MKL_CONSTRAINT=''
48
      pytorch_build="pytorch[build="*${version}*"]"
Nikita Shulga's avatar
Nikita Shulga committed
49
    fi
50
    set -x
51
52
53
54

    if [[ -z "$cudatoolkit" ]]; then
        conda install ${CONDA_CHANNEL_FLAGS:-} -y -c "pytorch-${UPLOAD_CHANNEL}" $MKL_CONSTRAINT "pytorch-${UPLOAD_CHANNEL}::${pytorch_build}"
    else
atalman's avatar
atalman committed
55
        conda install pytorch ${cudatoolkit} ${CONDA_CHANNEL_FLAGS:-} -y -c "pytorch-${UPLOAD_CHANNEL}" -c nvidia  $MKL_CONSTRAINT
56
    fi
57
)
58

moto's avatar
moto committed
59
# 2. Install torchaudio
60
printf "* Installing torchaudio\n"
61
python setup.py install
moto's avatar
moto committed
62
63
64

# 3. Install Test tools
printf "* Installing test tools\n"
Eli Uriegas's avatar
Eli Uriegas committed
65
NUMBA_DEV_CHANNEL=""
66
67
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
Eli Uriegas's avatar
Eli Uriegas committed
68
69
    # See https://github.com/librosa/librosa/issues/1270#issuecomment-759065048
    NUMBA_DEV_CHANNEL="-c numba/label/dev"
moto's avatar
moto committed
70
fi
Eli Uriegas's avatar
Eli Uriegas committed
71
72
73
# Note: installing librosa via pip fail because it will try to compile numba.
(
    set -x
74
    conda install -y -c conda-forge ${NUMBA_DEV_CHANNEL} 'librosa==0.10.0' parameterized 'requests>=2.20'
75
    pip install 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 pyroomacoustics
Eli Uriegas's avatar
Eli Uriegas committed
76
)
moto's avatar
moto committed
77
78
79
# Install fairseq
git clone https://github.com/pytorch/fairseq
cd fairseq
80
git checkout e47a4c8
moto's avatar
moto committed
81
pip install .