build_conda.sh 1.45 KB
Newer Older
rusty1s's avatar
rusty1s committed
1
2
#!/bin/bash

rusty1s's avatar
rusty1s committed
3
4
5
export PYTHON_VERSION=$1
export TORCH_VERSION=$2
export CUDA_VERSION=$3
rusty1s's avatar
rusty1s committed
6
7
8

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

rusty1s's avatar
rusty1s committed
9
10
if [ "${CUDA_VERSION}" = "cpu" ]; then
  export CONDA_CUDATOOLKIT_CONSTRAINT="cpuonly  # [not osx]"
rusty1s's avatar
rusty1s committed
11
12
else
  case $CUDA_VERSION in
rusty1s's avatar
update  
rusty1s committed
13
14
15
    cu117)
      export CONDA_CUDATOOLKIT_CONSTRAINT="pytorch-cuda==11.7.*"
      ;;
rusty1s's avatar
update  
rusty1s committed
16
    cu116)
rusty1s's avatar
update  
rusty1s committed
17
18
19
20
21
      if [ "${TORCH_VERSION}" = "1.12.0" ]; then
        export CONDA_CUDATOOLKIT_CONSTRAINT="cudatoolkit==11.6.*"
      else
        export CONDA_CUDATOOLKIT_CONSTRAINT="pytorch-cuda==11.6.*"
      fi
rusty1s's avatar
update  
rusty1s committed
22
      ;;
rusty1s's avatar
rusty1s committed
23
24
25
    cu115)
      export CONDA_CUDATOOLKIT_CONSTRAINT="cudatoolkit==11.5.*"
      ;;
rusty1s's avatar
rusty1s committed
26
27
28
    cu113)
      export CONDA_CUDATOOLKIT_CONSTRAINT="cudatoolkit==11.3.*"
      ;;
rusty1s's avatar
rusty1s committed
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
    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"

rusty1s's avatar
update  
rusty1s committed
49
if [ "${TORCH_VERSION}" = "1.12.0" ] && [ "${CUDA_VERSION}" = "cu116" ]; then
rusty1s's avatar
rusty1s committed
50
51
52
53
  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