-
Notifications
You must be signed in to change notification settings - Fork 2
/
install.sh
executable file
·170 lines (147 loc) · 5.94 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
#!/bin/bash
# This script will install SDM'Studio on this computer.
# To this end, the script will install dependencies, build and install SDMS.
# Accepts three parameters: torch_url, cplex_root, proc
# Usage: ./install.sh --torch_url=<URL/TO/PYTORCH.zip> --cplex_root=<PATH/TO/CPLEX_Studio> --proc=<NumProc>
# Variable declaration
CPLEX_ROOT='' # default is "/opt/ibm/ILOG/CPLEX_Studio201/"
TORCH_URL='' # default is pytorch for CPU
PROC='4' # the default number of processors used is 4
BLUE='\033[1;36m'
NC='\033[0m' # No Color
LOG_SDMS="${BLUE}SDMS#>${NC} "
# Parse arguments
for i in "$@"; do
case $i in
-t=*|--torch_url=*)
TORCH_URL="${i#*=}"
shift # past argument=value
;;
-c=*|--cplex_root=*)
CPLEX_ROOT="${i#*=}"
shift # past argument=value
;;
-p=*|--proc=*)
PROC="${i#*=}"
shift # past argument=value
;;
-h|--help)
echo -e "Usage: ./install.sh --torch_url=<URL/TO/PYTORCH.zip> --cplex_root=<PATH/TO/CPLEX_Studio> --proc=<NumProc>"
echo -e "-c,--cplex_root \n\tPath to the cplex directory (/opt/ibm/ILOG/CPLEX_Studio201/)"
echo -e "-h,--help \n\tShow this help"
echo -e "-p,--proc \n\tNumber of processors used during installation"
echo -e "-t,--torch_url \n\tUrl of the pytorch version (https://download.pytorch.org/libtorch/cpu/libtorch-cxx11-abi-shared-with-deps-1.7.1%2Bcpu.zip)"
exit 0
shift # past argument with no value
;;
-*|--*)
echo "Unknown option $i"
exit 1
;;
*)
;;
esac
done
# Get the platform name
unameOut="$(uname -s)"
case "${unameOut}" in
Linux*) machine=Linux;;
Darwin*) machine=Mac;;
CYGWIN*) machine=Cygwin;;
MINGW*) machine=MinGw;;
*) machine="UNKNOWN:${unameOut}"
esac
if [ "${machine}" == "Darwin" ]; # Install SDMS under Mac OS X platform
then
echo -e "${LOG_SDMS}Starting installation on Mac OS X platform"
echo -e "${LOG_SDMS}Install dependencies"
# Install dependencies
brew install eigen boost fmt gmp zlib zma unzip wget cmake clang
# port install eigen boost libfmt unzip wget
# Install PyTorch
url_libtorch='https://download.pytorch.org/libtorch/cpu/libtorch-macos-1.9.0.zip'
[[ -n ${TORCH_URL} ]] && url_libtorch=${TORCH_URL}
if [ ! -d /opt/libtorch ]; then
echo -e "\n${LOG_SDMS}Download PyTorch from $url_libtorch"
wget "$url_libtorch" -O /tmp/tmp_libtorch.zip && unzip /tmp/tmp_libtorch.zip -d /opt && rm /tmp/tmp_libtorch.zip
else
echo -e "${LOG_SDMS}PyTorch already installed"
fi
# Hard copy Toolbar library and other required libs
cp lib/* /usr/lib/x86_64-linux-gnu/
# Create build directory
echo -e "${LOG_SDMS}Create build directory."
rm -rf build
mkdir -p ./build && cd ./build
# Build and install SDM'Studio
echo -e "${LOG_SDMS}Build and install SDM'Studio."
if [ -n ${CPLEX_ROOT} ]; then
cmake -DCMAKE_BUILD_TYPE=Release -DCPLEX_ROOT_DIR="${CPLEX_ROOT}" .. && make -j ${PROC} install
else
cmake -DCMAKE_BUILD_TYPE=Release .. && make -j ${PROC} install
fi
# Check problem during SDMS installation
RESULT_INSTALL_SDMS=$?
if [ ${RESULT_INSTALL_SDMS} -eq 0 ];
then
echo -e "${LOG_SDMS}Installation completed. Use 'SDMStudio --help' to see how to use it."
else
echo -e "${LOG_SDMS}Something went wrong (code ${RESULT_INSTALL_SDMS}) when executing \"cmake .. && make -j install\""
echo -e "${LOG_SDMS}Installation will stop" && exit $?
fi
elif [ "${machine}" == "Linux" ]; # Install SDMS under GNU/Linux platform
then
declare -a dependencies=("libboost-all-dev" "libfmt-dev" "libgmp-dev" "zlib1g-dev" "liblzma-dev" "wget" "unzip" "cmake" "clang" )#libeigen3-dev
echo -e "${LOG_SDMS}Starting installation on Linux platform"
echo -e "${LOG_SDMS}Install dependencies"
# Install dependencies
for dependency in ${dependencies[@]}; do
echo -ne "- $dependency : "
if [ $(dpkg-query -W -f='${Status}' $dependency 2>/dev/null | grep -c "ok installed") -eq 0 ];
then
apt-get install -y ${dependency};
else
echo -e "installed"
fi
done
# Install PyTorch
url_libtorch='https://download.pytorch.org/libtorch/cpu/libtorch-cxx11-abi-shared-with-deps-1.7.1%2Bcpu.zip'
[[ -n ${TORCH_URL} ]] && url_libtorch=${TORCH_URL}
echo -ne "- pytorch : "
if [ ! -d /opt/libtorch ]; then
echo -e "\n${LOG_SDMS}Download PyTorch from $url_libtorch"
wget "$url_libtorch" -O /tmp/tmp_libtorch.zip && unzip /tmp/tmp_libtorch.zip -d /opt && rm /tmp/tmp_libtorch.zip
else
echo -e "installed"
fi
# Hard copy Toolbar library and other required libs
cp lib/* /usr/lib/x86_64-linux-gnu/
# Create build directory
echo -e "${LOG_SDMS}Create build directory."
rm -rf build
mkdir -p ./build && cd ./build
# Build and install SDM'Studio
echo -e "${LOG_SDMS}Build and install SDM'Studio."
if [ -n ${CPLEX_ROOT} ]; then
cmake -DCMAKE_BUILD_TYPE=Release -DCPLEX_ROOT_DIR="${CPLEX_ROOT}" .. && make -j ${PROC} install
else
cmake -DCMAKE_BUILD_TYPE=Release .. && make -j ${PROC} install
fi
# Check problem during SDMS installation
RESULT_INSTALL_SDMS=$?
if [ ${RESULT_INSTALL_SDMS} -eq 0 ];
then
echo -e "${LOG_SDMS}Installation completed. Use 'SDMStudio --help' to see how to use it."
else
echo -e "${LOG_SDMS}Something went wrong (code ${RESULT_INSTALL_SDMS}) when executing \"cmake .. && make -j install\""
echo -e "${LOG_SDMS}Installation will stop" && exit $?
fi
elif [ "${machine}" == "MINGW32_NT" ];
then
# Do something under 32 bits Windows NT platform
echo -e "${LOG_SDMS}SDM'Studio is not available for 32 bits Windows NT platform"
elif [ "${machine}" == "MINGW64_NT" ];
then
# Do something under 64 bits Windows NT platform
echo -e "${LOG_SDMS}SDM'Studio is not available for 64 bits Windows NT platform"
fi