build_conda.sh 1.53 KB
Newer Older
rusty1s's avatar
rusty1s committed
1
2
3
4
5
6
7
8
9
#!/bin/bash

export PYTHON_VERSION=$1
export TORCH_VERSION=$2
export CUDA_VERSION=$3

export CONDA_PYTORCH_CONSTRAINT="pytorch==${TORCH_VERSION%.*}.*"

if [ "${CUDA_VERSION}" = "cpu" ]; then
rusty1s's avatar
rusty1s committed
10
  export CONDA_CUDATOOLKIT_CONSTRAINT="cpuonly  # [not osx]"
rusty1s's avatar
rusty1s committed
11
12
else
  case $CUDA_VERSION in
Matthias Fey's avatar
Matthias Fey committed
13
14
15
    cu118)
      export CONDA_CUDATOOLKIT_CONSTRAINT="pytorch-cuda==11.8.*"
      ;;
Matthias Fey's avatar
Matthias Fey committed
16
17
18
    cu117)
      export CONDA_CUDATOOLKIT_CONSTRAINT="pytorch-cuda==11.7.*"
      ;;
Matthias Fey's avatar
Matthias Fey committed
19
    cu116)
Matthias Fey's avatar
Matthias Fey committed
20
21
22
23
24
      if [ "${TORCH_VERSION}" = "1.12.0" ]; then
        export CONDA_CUDATOOLKIT_CONSTRAINT="cudatoolkit==11.6.*"
      else
        export CONDA_CUDATOOLKIT_CONSTRAINT="pytorch-cuda==11.6.*"
      fi
Matthias Fey's avatar
Matthias Fey committed
25
      ;;
rusty1s's avatar
rusty1s committed
26
27
28
    cu115)
      export CONDA_CUDATOOLKIT_CONSTRAINT="cudatoolkit==11.5.*"
      ;;
rusty1s's avatar
rusty1s committed
29
30
31
    cu113)
      export CONDA_CUDATOOLKIT_CONSTRAINT="cudatoolkit==11.3.*"
      ;;
rusty1s's avatar
rusty1s committed
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
    cu111)
      export CONDA_CUDATOOLKIT_CONSTRAINT="cudatoolkit==11.1.*"
      ;;
    cu102)
      export CONDA_CUDATOOLKIT_CONSTRAINT="cudatoolkit==10.2.*"
      ;;
    cu101)
      export CONDA_CUDATOOLKIT_CONSTRAINT="cudatoolkit==10.1.*"
      ;;
    *)
      echo "Unrecognized CUDA_VERSION=$CUDA_VERSION"
      exit 1
      ;;
  esac
fi

echo "PyTorch $TORCH_VERSION+$CUDA_VERSION"
echo "- $CONDA_PYTORCH_CONSTRAINT"
echo "- $CONDA_CUDATOOLKIT_CONSTRAINT"

Matthias Fey's avatar
Matthias Fey committed
52
if [ "${TORCH_VERSION}" = "1.12.0" ] && [ "${CUDA_VERSION}" = "cu116" ]; then
rusty1s's avatar
rusty1s committed
53
54
55
56
  conda build . -c pytorch -c default -c nvidia -c conda-forge --output-folder "$HOME/conda-bld"
else
  conda build . -c pytorch -c default -c nvidia --output-folder "$HOME/conda-bld"
fi