Skip to content

Commit 7cf1e4c

Browse files
committed
install script refactor: install torch outside of detectron2 install sction
1 parent cd6c6b2 commit 7cf1e4c

File tree

2 files changed

+26
-25
lines changed

2 files changed

+26
-25
lines changed

scripts/install.sh

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,22 @@ mkdir -p ${MODELS_WEIGHT_DIR}
7171
## Make sure we have up-to-date pip and wheel
7272
pip3 install -U pip wheel
7373

74+
if [ "${CUDA_VERSION}" == "" ] && [ "${CPU}" == "False" ]; then
75+
CUDA_VERSION=$(nvcc --version | sed -n 's/^.*release \([0-9]\+\.[0-9]\+\).*$/\1/p')
76+
if [ ${CUDA_VERSION} == "" ]; then
77+
echo "error with cuda, check your system, source env_cuda.sh or specify cuda version as argument."
78+
fi
79+
fi
80+
if [ -z "$CUDA_VERSION" ] || [ "$CPU" == "True" ]; then
81+
echo "installing on cpu"
82+
pip3 install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cpu
83+
wait
84+
else
85+
echo "cuda version: $CUDA_VERSION"
86+
pip3 install torch==${TORCH_VERSION}+cu${CUDA_VERSION//./} torchvision==${TORCHVISION_VERSION}+cu${CUDA_VERSION//./} --extra-index-url https://download.pytorch.org/whl/cu${CUDA_VERSION//./}
87+
wait
88+
fi
89+
7490
## Detectron2
7591
if [ "${MODEL,,}" == "detectron2" ] || [ ${MODEL} == "all" ]; then
7692

@@ -89,22 +105,6 @@ if [ "${MODEL,,}" == "detectron2" ] || [ ${MODEL} == "all" ]; then
89105
echo
90106
git -c advice.detachedHead=false checkout 175b2453c2bc4227b8039118c01494ee75b08136
91107

92-
if [ "${CUDA_VERSION}" == "" ] && [ "${CPU}" == "False" ]; then
93-
CUDA_VERSION=$(nvcc --version | sed -n 's/^.*release \([0-9]\+\.[0-9]\+\).*$/\1/p')
94-
if [ ${CUDA_VERSION} == "" ]; then
95-
echo "error with cuda, check your system, source env_cuda.sh or specify cuda version as argument."
96-
fi
97-
fi
98-
if [ -z "$CUDA_VERSION" ] || [ "$CPU" == "True" ]; then
99-
echo "installing on cpu"
100-
pip3 install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cpu
101-
wait
102-
else
103-
echo "cuda version: $CUDA_VERSION"
104-
pip3 install torch==${TORCH_VERSION}+cu${CUDA_VERSION//./} torchvision==${TORCHVISION_VERSION}+cu${CUDA_VERSION//./} --extra-index-url https://download.pytorch.org/whl/cu${CUDA_VERSION//./}
105-
wait
106-
fi
107-
108108
# '!' egating set -e when patching has been applied already
109109
! patch -p1 --forward <${SCRIPT_DIR}/0001-detectron2-fpn-bottom-up-separate.patch
110110

scripts/install_uv.sh

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,16 @@ mkdir -p ${MODELS_WEIGHT_DIR}
7171
## Make sure we have up-to-date pip and wheel
7272
uv add --upgrade pip wheel
7373

74+
if [ -z "$CUDA_VERSION" ] || [ "$CPU" == "True" ]; then
75+
echo "installing on cpu"
76+
uv pip install torch torchvision torchaudio --default-index https://download.pytorch.org/whl/cpu
77+
wait
78+
else
79+
echo "cuda version: $CUDA_VERSION"
80+
uv pip install torch==${TORCH_VERSION}+cu${CUDA_VERSION//./} torchvision==${TORCHVISION_VERSION}+cu${CUDA_VERSION//./} --extra-index-url https://download.pytorch.org/whl/cu${CUDA_VERSION//./}
81+
wait
82+
fi
83+
7484
## Detectron2
7585
if [ "${MODEL,,}" == "detectron2" ] || [ ${MODEL} == "all" ]; then
7686

@@ -95,15 +105,6 @@ if [ "${MODEL,,}" == "detectron2" ] || [ ${MODEL} == "all" ]; then
95105
echo "error with cuda, check your system, source env_cuda.sh or specify cuda version as argument."
96106
fi
97107
fi
98-
if [ -z "$CUDA_VERSION" ] || [ "$CPU" == "True" ]; then
99-
echo "installing on cpu"
100-
uv pip install torch torchvision torchaudio --default-index https://download.pytorch.org/whl/cpu
101-
wait
102-
else
103-
echo "cuda version: $CUDA_VERSION"
104-
uv pip install torch==${TORCH_VERSION}+cu${CUDA_VERSION//./} torchvision==${TORCHVISION_VERSION}+cu${CUDA_VERSION//./} --extra-index-url https://download.pytorch.org/whl/cu${CUDA_VERSION//./}
105-
wait
106-
fi
107108

108109
# '!' egating set -e when patching has been applied already
109110
! patch -p1 --forward <${SCRIPT_DIR}/0001-detectron2-fpn-bottom-up-separate.patch

0 commit comments

Comments
 (0)