install.sh 1.42 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
10
11
12

eval "$(./conda/bin/conda shell.bash hook)"
conda activate ./env

guyang3532's avatar
guyang3532 committed
13
if [ "${CU_VERSION:-}" == cpu ] ; then
14
    cudatoolkit="cpuonly"
15
    version="cpu"
16
else
guyang3532's avatar
guyang3532 committed
17
18
19
20
21
    if [[ ${#CU_VERSION} -eq 4 ]]; then
        CUDA_VERSION="${CU_VERSION:2:1}.${CU_VERSION:3:1}"
    elif [[ ${#CU_VERSION} -eq 5 ]]; then
        CUDA_VERSION="${CU_VERSION:2:2}.${CU_VERSION:4:1}"
    fi
Andrey Talman's avatar
Andrey Talman committed
22
    echo "Using CUDA $CUDA_VERSION as determined by CU_VERSION: ${CU_VERSION} "
23
    version="$(python -c "print('.'.join(\"${CUDA_VERSION}\".split('.')[:2]))")"
Andrey Talman's avatar
Andrey Talman committed
24
    cudatoolkit="pytorch-cuda=${version}"
25
fi
26

27
28
29
30
31
case "$(uname -s)" in
    Darwin*) os=MacOSX;;
    *) os=Linux
esac

32
printf "Installing PyTorch with %s\n" "${cudatoolkit}"
33
if [ "${os}" == "MacOSX" ]; then
34
    conda install -y -c "pytorch-${UPLOAD_CHANNEL}" "pytorch-${UPLOAD_CHANNEL}"::pytorch "${cudatoolkit}"
35
else
36
    conda install -y -c "pytorch-${UPLOAD_CHANNEL}" -c nvidia "pytorch-${UPLOAD_CHANNEL}"::pytorch[build="*${version}*"] "${cudatoolkit}"
37
38
39
40

    # make sure local cuda is set to required cuda version and not CUDA version by default
    rm -f /usr/local/cuda
    ln -s /usr/local/cuda-${version} /usr/local/cuda
41
fi
42

43

44
printf "* Installing torchvision\n"
45
python setup.py develop