forked from IntelLabs/coach
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstall.sh
executable file
·201 lines (171 loc) · 6.4 KB
/
install.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
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
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
#!/bin/bash -e
prompt () {
# prints a yes / no question to the user and returns the answer
# first argument is the prompt question
# second argument is the default answer - Y / N
local default_answer
# set the default value
case "${2}" in
y|Y ) default_answer=1; options="[Y/n]";;
n|N ) default_answer=0; options="[y/N]";;
"" ) default_answer=; options="[y/n]";;
* ) echo "invalid default value"; exit;;
esac
while true; do
# read the user choice
read -p "${1} ${options} " choice
# return the choice or the default value if an enter was pressed
case "${choice}" in
y|Y ) retval=1; return;;
n|N ) retval=0; return;;
"" ) if [ ! -z "${default_answer}" ]; then retval=${default_answer}; return; fi;;
esac
done
}
add_to_bashrc () {
# adds an env variable to the bashrc
# first argument is the variable name
# second argument is the variable value
EXISTS_IN_BASHRC=`awk '/${2}/{print $1}' ~/.bashrc`
if [ "${EXISTS_IN_BASHRC}" == "" ]; then
echo "export ${1}=${2}" >> ~/.bashrc
fi
}
GET_PREFERENCES_MANUALLY=1
INSTALL_COACH=0
INSTALL_DASHBOARD=0
INSTALL_GYM=0
INSTALL_VIRTUAL_ENVIRONMENT=1
INSTALL_NEON=0
# Get user preferences
TEMP=`getopt -o cpgvrmeNndh \
--long coach,dashboard,gym,no_virtual_environment,neon,debug,help \
-- "$@"`
eval set -- "$TEMP"
while true; do
#for i in "$@"
case ${1} in
-c|--coach)
INSTALL_COACH=1
GET_PREFERENCES_MANUALLY=0
shift;;
-p|--dashboard)
INSTALL_DASHBOARD=1
GET_PREFERENCES_MANUALLY=0;
shift;;
-g|--gym)
INSTALL_GYM=1
GET_PREFERENCES_MANUALLY=0;
shift;;
-N|--no_virtual_environment)
INSTALL_VIRTUAL_ENVIRONMENT=0
GET_PREFERENCES_MANUALLY=0;
shift;;
-ne|--neon)
INSTALL_NEON=1
GET_PREFERENCES_MANUALLY=0;
shift;;
-d|--debug) set -x; shift;;
-h|--help)
echo "Available command line arguments:"
echo ""
echo " -c | --coach - Install Coach requirements"
echo " -p | --dashboard - Install Dashboard requirements"
echo " -g | --gym - Install Gym support"
echo " -N | --no_virtual_environment - Do not install inside of a virtual environment"
echo " -d | --debug - Run in debug mode"
echo " -h | --help - Display this help message"
echo ""
exit;;
--) shift; break;;
*) break;; # unknown option;;
esac
done
if [ ${GET_PREFERENCES_MANUALLY} -eq 1 ]; then
prompt "Install Coach requirements?" Y
INSTALL_COACH=${retval}
prompt "Install Dashboard requirements?" Y
INSTALL_DASHBOARD=${retval}
prompt "Install Gym support?" Y
INSTALL_GYM=${retval}
prompt "Install neon support?" Y
INSTALL_NEON=${retval}
fi
IN_VIRTUAL_ENV=`python3 -c 'import sys; print("%i" % hasattr(sys, "real_prefix"))'`
# basic installations
sudo -E apt-get install python3-pip cmake zlib1g-dev python3-tk python-opencv -y
pip3 install --upgrade pip
# if we are not in a virtual environment, we will create one with the appropriate python version and then activate it
# if we are already in a virtual environment,
if [ ${INSTALL_VIRTUAL_ENVIRONMENT} -eq 1 ]; then
if [ ${IN_VIRTUAL_ENV} -eq 0 ]; then
sudo -E pip3 install virtualenv
virtualenv -p python3 coach_env
. coach_env/bin/activate
fi
fi
#------------------------------------------------
# From now on we are in a virtual environment
#------------------------------------------------
# get python local and global paths
python_version=python$(python -c "import sys; print (str(sys.version_info[0])+'.'+str(sys.version_info[1]))")
var=( $(which -a $python_version) )
get_python_lib_cmd="from distutils.sysconfig import get_python_lib; print (get_python_lib())"
lib_virtualenv_path=$(python -c "$get_python_lib_cmd")
lib_system_path=$(${var[-1]} -c "$get_python_lib_cmd")
# Boost libraries
sudo -E apt-get install libboost-all-dev -y
# Coach
if [ ${INSTALL_COACH} -eq 1 ]; then
echo "Installing Coach requirements"
pip3 install -r ./requirements_coach.txt
fi
# Dashboard
if [ ${INSTALL_DASHBOARD} -eq 1 ]; then
echo "Installing Dashboard requirements"
pip3 install -r ./requirements_dashboard.txt
sudo -E apt-get install dpkg-dev build-essential python3.5-dev libjpeg-dev libtiff-dev libsdl1.2-dev libnotify-dev \
freeglut3 freeglut3-dev libsm-dev libgtk2.0-dev libgtk-3-dev libwebkitgtk-dev libgtk-3-dev libwebkitgtk-3.0-dev libgstreamer-plugins-base1.0-dev -y
sudo -E -H pip3 install -U --pre -f \
https://wxpython.org/Phoenix/snapshot-builds/linux/gtk3/ubuntu-16.04/wxPython-4.0.0a3.dev3059+4a5c5d9-cp35-cp35m-linux_x86_64.whl wxPython
# link wxPython Phoenix library into the virtualenv since it is installed with apt-get and not accessible
libs=( wx )
for lib in ${libs[@]}
do
ln -s $lib_system_path/$lib $lib_virtualenv_path/$lib
done
fi
# Gym
if [ ${INSTALL_GYM} -eq 1 ]; then
echo "Installing Gym support"
sudo -E apt-get install libav-tools libsdl2-dev swig cmake -y
pip3 install box2d # for bipedal walker etc.
pip3 install gym
fi
# NGraph and Neon
if [ ${INSTALL_NEON} -eq 1 ]; then
echo "Installing neon requirements"
# MKL
git clone https://github.com/01org/mkl-dnn.git
cd mkl-dnn
cd scripts && ./prepare_mkl.sh && cd ..
mkdir -p build && cd build && cmake .. && make -j
sudo make install -j
cd ../..
export MKLDNN_ROOT=/usr/local/
add_to_bashrc MKLDNN_ROOT ${MKLDNN_ROOT}
export LD_LIBRARY_PATH=$MKLDNN_ROOT/lib:$LD_LIBRARY_PATH
add_to_bashrc LD_LIBRARY_PATH ${MKLDNN_ROOT}/lib:$LD_LIBRARY_PATH
# NGraph
git clone https://github.com/NervanaSystems/ngraph.git
cd ngraph
make install -j
cd ..
# Neon
sudo -E apt-get install libhdf5-dev libyaml-dev pkg-config clang virtualenv libcurl4-openssl-dev libopencv-dev libsox-dev -y
git clone https://github.com/NervanaSystems/neon.git
cd neon && make sysinstall -j
cd ..
fi
# Intel Optimized TensorFlow
pip3 install https://anaconda.org/intel/tensorflow/1.3.0/download/tensorflow-1.3.0-cp35-cp35m-linux_x86_64.whl