-
Notifications
You must be signed in to change notification settings - Fork 47
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·179 lines (158 loc) · 5.03 KB
/
install.sh
File metadata and controls
executable file
·179 lines (158 loc) · 5.03 KB
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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
#!/usr/bin/env bash
# This script (c) 2024 Hello Robot under the MIT license: https://opensource.org/licenses/MIT
# This script is designed to install the HomeRobot/StretchPy environment.
export PYTHON_VERSION=3.10
script_dir="$(dirname "$0")"
VERSION=`python3 $script_dir/src/stretch/version.py`
CPU_ONLY="false"
NO_REMOVE="false"
NO_SUBMODULES="false"
MAMBA=mamba
NO_VERSION="false"
# Two cases: -y for yes, --cpu for cpu only
# One more: --conda for conda
for arg in "$@"
do
case $arg in
-y|--yes)
yn="y"
SKIP_ASKING="true"
shift
;;
--cpu)
CPU_ONLY="true"
shift
;;
--conda)
MAMBA=conda
shift
;;
--no-remove)
NO_REMOVE="true"
shift
;;
--no-submodules)
NO_SUBMODULES="true"
shift
;;
--no-version)
NO_VERSION="true"
shift
;;
*)
shift
# unknown option
;;
esac
done
# Check if the user has the required packages
# If not, install them
# If these packages are not installed, you will run into issues with pyaudio
sudo apt-get update
echo "Checking for required packages: "
echo " libasound-dev portaudio19-dev libportaudio2 libportaudiocpp0 espeak ffmpeg"
echo "If these are not installed, you will run into issues with pyaudio."
if [ "$SKIP_ASKING" == "true" ]; then
sudo apt-get install libasound-dev portaudio19-dev libportaudio2 libportaudiocpp0 espeak ffmpeg build-essential wget unzip libsndfile1 -y
else
sudo apt-get install libasound-dev portaudio19-dev libportaudio2 libportaudiocpp0 espeak ffmpeg build-essential wget unzip libsndfile1
fi
# If cpu only, set the cuda version to cpu
if [ "$CPU_ONLY" == "true" ]; then
if [ "$NO_VERSION" == "true" ]; then
ENV_NAME=stretch_ai_cpu
else
ENV_NAME=stretch_ai_cpu_${VERSION}
fi
ENV_NAME=stretch_ai_cpu_${VERSION}
else
if [ "$NO_VERSION" == "true" ]; then
ENV_NAME=stretch_ai
else
ENV_NAME=stretch_ai_${VERSION}
fi
fi
echo "=============================================="
echo " INSTALLING STRETCH AI TOOLS"
echo "=============================================="
echo "---------------------------------------------"
echo "Environment name: $ENV_NAME"
echo "Python Version: $PYTHON_VERSION"
echo "Using tool: $MAMBA"
echo "---------------------------------------------"
echo "Notes:"
echo " - This script will remove the existing environment if it exists."
echo " - This script will install the following packages:"
echo " - torchvision"
if [[ $INSTALL_TORCH_GEOMETRIC == "true" ]]; then
echo " - torch-geometric"
echo " - torch-cluster"
echo " - torch-scatter"
fi
echo " - python=$PYTHON_VERSION"
echo "---------------------------------------------"
echo "Currently:"
echo " - python=`which python`"
# if -y flag was passed in, do not bother asking
#
if [ "$SKIP_ASKING" == "true" ]; then
yn="y"
else
read -p "Does all this look correct? (y/n) " yn
case $yn in
y ) echo "Starting installation..." ;;
n ) echo "Exiting...";
exit ;;
* ) echo Invalid response!;
exit 1 ;;
esac
fi
# Exit immediately if anything fails
set -e
# Install git-lfs
echo "Installing git-lfs..."
echo "If this fails, install git-lfs with:"
echo ""
echo " sudo apt-get install git-lfs"
echo ""
git lfs install
# Only remove if NO_REMOVe is false
if [ "$NO_REMOVE" == "false" ]; then
echo "Removing existing environment..."
$MAMBA env remove -n $ENV_NAME -y || true
fi
$MAMBA create -n $ENV_NAME python=$PYTHON_VERSION -y
echo "Activate env $ENV_NAME"
# If you don't install conda and only have mamba, please don't use this script from here and manually install everything.
eval "$(conda shell.bash hook)"
source activate $ENV_NAME
echo "Install a version of setuptools for which clip works."
python -m pip install setuptools==69.5.1
echo ""
echo "---------------------------------------------"
echo "---- INSTALLING STRETCH AI DEPENDENCIES ----"
echo "Will be installed via pip into env: $ENV_NAME"
if [ "$CPU_ONLY" = "false" ]; then
echo "Installing segment-anything-2..."
cd third_party/segment-anything-2
python -m pip install -e . --no-cache-dir
cd ../..
else
# Provide feedback if the condition is not met
echo "Skipping segment-anything-2 installation because CPU_ONLY is 'true'."
fi
echo "Installing other stretch-ai dependencies"
python -m pip install -e ./src[dev] --no-cache-dir
# Uninstall av to avoid conflict between torchvision and cv2.imshow
python -m pip uninstall av -y
echo ""
echo "=============================================="
echo " INSTALLATION COMPLETE"
echo "Finished setting up the StretchPy environment."
echo "Environment name: $ENV_NAME"
echo "Python Version: $PYTHON_VERSION"
echo "python=`which python`"
echo "You can start using it with:"
echo ""
echo " $MAMBA activate $ENV_NAME"
echo "=============================================="