-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstall_dependencies_Linux.sh
65 lines (52 loc) · 1.71 KB
/
install_dependencies_Linux.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
if [[ -z "${install_dir}" ]]
then
install_dir="$SCRIPT_DIR"
fi
# python3 executable
python_cmd="python3"
# git executable
export GIT="git"
# python3 venv without trailing slash (defaults to ${install_dir}/${clone_dir}/venv)
venv_dir="venv"
ENV_SCRIPT="prepare_environment.py"
# Disable sentry logging
export ERROR_REPORTING=FALSE
# Do not reinstall existing pip packages on Debian/Ubuntu
export PIP_IGNORE_INSTALLED=0
gpu_info=$(lspci 2>/dev/null | grep -E "VGA|Display")
if ! echo "$gpu_info" | grep -q "NVIDIA";
then
if echo "$gpu_info" | grep -q "AMD" && [[ -z "${TORCH_COMMAND}" ]]
then
export TORCH_COMMAND="pip install torch torchvision --index-url https://download.pytorch.org/whl/rocm6.1"
fi
fi
if ! "${python_cmd}" -c "import venv" &>/dev/null
then
printf "\n%s\n" "${delimiter}"
printf "\e[1m\e[31mERROR: python3-venv is not installed, aborting...\e[0m"
printf "\n%s\n" "${delimiter}"
exit 1
fi
printf "\e[1m\e[32mInstalling dependencies for Volume Seg Tool...\n"
if [[ -z "${VIRTUAL_ENV}" ]];
then
printf "Creating and activating python venv\n"
cd "${install_dir}"/ || { printf "\e[1m\e[31mERROR: Can't cd to %s/, aborting...\e[0m" "${install_dir}"; exit 1; }
if [[ ! -d "${venv_dir}" ]]
then
"${python_cmd}" -m venv "${venv_dir}"
fi
# shellcheck source=/dev/null
if [[ -f "${venv_dir}"/bin/activate ]]
then
source "${venv_dir}"/bin/activate
else
printf "\e[1m\e[31mERROR: Cannot activate python venv, aborting...\e[0m"
exit 1
fi
else
printf "python venv already activate: ${VIRTUAL_ENV}"
fi
"${python_cmd}" -u "${ENV_SCRIPT}" "$@"