-
Notifications
You must be signed in to change notification settings - Fork 13
/
grps_env.sh
182 lines (169 loc) · 5.33 KB
/
grps_env.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
#!/bin/bash
# Copyright 2023 netease. All rights reserved.
# Author zhaochaochao@corp.netease.com
# Date 2023/8/18
# Brief Environment install.
COLORRED="\033[31m"
COLORGREEN="\033[32m"
COLORYELLOW="\033[33m"
COLOREND="\033[0m"
function LOG() {
date_str=$(date "+%Y-%m-%d %H:%M:%S")
case "$1" in
"WARNING")
shift
echo -e "${COLORYELLOW}WARNING $(date "+%Y-%m-%d %H:%M:%S") $* $COLOREND"
;;
"ERROR")
shift
echo -e "${COLORRED}ERROR $(date "+%Y-%m-%d %H:%M:%S") $* $COLOREND"
;;
*)
echo -e "${COLORGREEN}INFO $(date "+%Y-%m-%d %H:%M:%S") $* $COLOREND"
;;
esac
}
function check_ret() {
if [ $? -ne 0 ]; then
LOG ERROR "$1 failed."
exit 1
fi
}
function run_and_check() {
$*
check_ret "$*"
}
# check if is root.
if [ "$EUID" -ne 0 ]; then
LOG ERROR "Please run as root."
exit
fi
cuda_enable= # If setup cuda.
py_enable= # If setup python support.
cpp_enable= # If setup cpp support.
cpp_torch_enable= # If setup cpp torch support.
cpp_tf_enable= # If setup cpp tensorflow support.
cpp_trt_enable= # If setup cpp tensorrt support.
if [ "$cuda_enable" = "" ]; then
echo "Select if setup CUDA, yes or no, default is yes?"
read cuda_enable
fi
if [ "$cuda_enable" = "yes" -o "$cuda_enable" = "y" -o "$cuda_enable" = "" ]; then
cuda_path="/usr/local/cuda"
if [ ! -d "$cuda_path" ]; then
LOG ERROR "CUDA path $cuda_path not exist."
exit 1
fi
LOG INFO "CUDA is setup, path is $cuda_path."
cuda_enable="1"
else
LOG INFO "CUDA is not setup."
cuda_enable="0"
cuda_path=""
fi
if [ "$py_enable" = "" ]; then
echo "Select if setup python support, yes or no, default is yes?"
read py_enable
fi
if [ "$py_enable" = "yes" -o "$py_enable" = "y" -o "$py_enable" = "" ]; then
LOG INFO "python support is setup."
py_enable="1"
else
LOG INFO "python support is not setup."
py_enable="0"
fi
if [ "$cpp_enable" = "" ]; then
echo "Select if setup cpp support, yes or no, default is yes?"
read cpp_enable
fi
if [ "$cpp_enable" = "yes" -o "$cpp_enable" = "y" -o "$cpp_enable" = "" ]; then
LOG INFO "cpp support is setup."
cpp_enable="1"
else
LOG INFO "cpp support is not setup."
cpp_enable="0"
fi
if [ "$cpp_enable" = "1" ]; then
if [ "$cpp_torch_enable" = "" ]; then
echo "Select if setup cpp torch support, yes or no, default is yes?"
read cpp_torch_enable
fi
if [ "$cpp_torch_enable" = "yes" -o "$cpp_torch_enable" = "y" -o "$cpp_torch_enable" = "" ]; then
libtorch_path="/usr/local/libtorch"
if [ ! -d "$libtorch_path" ]; then
LOG ERROR "libtorch path $libtorch_path not exist."
exit 1
fi
if [ ! -d "$libtorch_path/lib" ]; then
LOG ERROR "libtorch path $libtorch_path/lib not exist."
exit 1
fi
LOG INFO "cpp torch is setup, lib path is $libtorch_path."
cpp_torch_enable="1"
else
LOG INFO "cpp torch is not setup."
cpp_torch_enable="0"
libtorch_path=""
fi
if [ "$cpp_tf_enable" = "" ]; then
echo "Select if setup cpp tensorflow support, yes or no, default is yes?"
read cpp_tf_enable
fi
if [ "$cpp_tf_enable" = "yes" -o "$cpp_tf_enable" = "y" -o "$cpp_tf_enable" = "" ]; then
libtensorflow_path="/usr/local/libtensorflow"
if [ ! -d "$libtensorflow_path" ]; then
LOG ERROR "libtensorflow path $libtensorflow_path not exist."
exit 1
fi
if [ ! -d "$libtensorflow_path/lib" ]; then
LOG ERROR "libtensorflow path $libtensorflow_path/lib not exist."
exit 1
fi
LOG INFO "cpp tensorflow is setup, lib path is $libtensorflow_path."
cpp_tf_enable="1"
else
LOG INFO "cpp tensorflow is not setup."
cpp_tf_enable="0"
libtensorflow_path=""
fi
if [ "$cpp_trt_enable" = "" ]; then
echo "Select if setup cpp tensorrt support, yes or no, default is yes?"
read cpp_trt_enable
fi
if [ "$cpp_trt_enable" = "yes" -o "$cpp_trt_enable" = "y" -o "$cpp_trt_enable" = "" ]; then
libtensorrt_path="/usr/local/libtensorrt"
if [ ! -d "$libtensorrt_path" ]; then
LOG ERROR "libtensorrt path $libtensorrt_path not exist."
exit 1
fi
if [ ! -d "$libtensorrt_path/lib" ]; then
LOG ERROR "libtensorrt path $libtensorrt_path/lib not exist."
exit 1
fi
LOG INFO "cpp tensorrt is setup, lib path is $libtensorrt_path."
cpp_trt_enable="1"
else
LOG INFO "cpp tensorrt is not setup."
cpp_trt_enable="0"
libtensorrt_path=""
fi
else
cpp_torch_enable="0"
libtorch_path=""
cpp_tf_enable="0"
libtensorflow_path=""
cpp_trt_enable="0"
libtensorrt_path=""
fi
LOG INFO "cuda_enable=$cuda_enable py_enable=$py_enable cpp_enable=$cpp_enable cpp_torch_enable=$cpp_torch_enable \
libtorch_path=$libtorch_path cpp_tf_enable=$cpp_tf_enable libtensorflow_path=$libtensorflow_path \
cpp_trt_enable=$cpp_trt_enable libtensorrt_path=$libtensorrt_path"
echo "cuda_enable=$cuda_enable" >.config
echo "py_enable=$py_enable" >>.config
echo "cpp_enable=$cpp_enable" >>.config
echo "cpp_torch_enable=$cpp_torch_enable" >>.config
echo "libtorch_path=$libtorch_path" >>.config
echo "cpp_tf_enable=$cpp_tf_enable" >>.config
echo "libtensorflow_path=$libtensorflow_path" >>.config
echo "cpp_trt_enable=$cpp_trt_enable" >>.config
echo "libtensorrt_path=$libtensorrt_path" >>.config