|
| 1 | +#!/usr/bin/env bash |
| 2 | + |
| 3 | +unset PYTORCH_VERSION |
| 4 | +# For unittest, nightly PyTorch is used as the following section, |
| 5 | +# so no need to set PYTORCH_VERSION. |
| 6 | +# In fact, keeping PYTORCH_VERSION forces us to hardcode PyTorch version in config. |
| 7 | + |
| 8 | +set -e |
| 9 | + |
| 10 | +eval "$(./conda/bin/conda shell.bash hook)" |
| 11 | +conda activate ./env |
| 12 | + |
| 13 | +if [ "${CU_VERSION:-}" == cpu ] ; then |
| 14 | + version="cpu" |
| 15 | +else |
| 16 | + if [[ ${#CU_VERSION} -eq 4 ]]; then |
| 17 | + CUDA_VERSION="${CU_VERSION:2:1}.${CU_VERSION:3:1}" |
| 18 | + elif [[ ${#CU_VERSION} -eq 5 ]]; then |
| 19 | + CUDA_VERSION="${CU_VERSION:2:2}.${CU_VERSION:4:1}" |
| 20 | + fi |
| 21 | + echo "Using CUDA $CUDA_VERSION as determined by CU_VERSION ($CU_VERSION)" |
| 22 | + version="$(python -c "print('.'.join(\"${CUDA_VERSION}\".split('.')[:2]))")" |
| 23 | +fi |
| 24 | + |
| 25 | +# submodules |
| 26 | +git submodule sync && git submodule update --init --recursive |
| 27 | + |
| 28 | +printf "Installing PyTorch with cu121" |
| 29 | +if [[ "$TORCH_VERSION" == "nightly" ]]; then |
| 30 | + if [ "${CU_VERSION:-}" == cpu ] ; then |
| 31 | + pip3 install --pre torch --index-url https://download.pytorch.org/whl/nightly/cpu -U |
| 32 | + else |
| 33 | + pip3 install --pre torch --index-url https://download.pytorch.org/whl/nightly/cu121 -U |
| 34 | + fi |
| 35 | +elif [[ "$TORCH_VERSION" == "stable" ]]; then |
| 36 | + if [ "${CU_VERSION:-}" == cpu ] ; then |
| 37 | + pip3 install torch --index-url https://download.pytorch.org/whl/cpu |
| 38 | + else |
| 39 | + pip3 install torch --index-url https://download.pytorch.org/whl/cu121 |
| 40 | + fi |
| 41 | +else |
| 42 | + printf "Failed to install pytorch" |
| 43 | + exit 1 |
| 44 | +fi |
| 45 | + |
| 46 | +# install tensordict |
| 47 | +if [[ "$RELEASE" == 0 ]]; then |
| 48 | + pip3 install git+https://github.com/pytorch/tensordict.git |
| 49 | +else |
| 50 | + pip3 install tensordict |
| 51 | +fi |
| 52 | + |
| 53 | +# smoke test |
| 54 | +python -c "import functorch;import tensordict" |
| 55 | + |
| 56 | +printf "* Installing torchrl\n" |
| 57 | +python setup.py develop |
| 58 | + |
| 59 | +# smoke test |
| 60 | +python -c "import torchrl" |
0 commit comments