build_conda.sh 909 Bytes
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
11
if [[ "$(uname)" == Darwin ]]; then
    export CONDA_CUDATOOLKIT_CONSTRAINT=""
elif [ "${CUDA_VERSION}" = "cpu" ]; then
rusty1s's avatar
rusty1s committed
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
  export CONDA_CUDATOOLKIT_CONSTRAINT="cpuonly"
else
  case $CUDA_VERSION in
    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
rusty1s committed
35
conda build . -c defaults -c nvidia -c pytorch -c conda-forge --output-folder "$HOME/conda-bld"