17
17
# # * OSX
18
18
# # =================================================================
19
19
20
+
20
21
# Determine OS platform
21
22
UNAME=$( uname | tr " [:upper:]" " [:lower:]" )
22
23
# If Linux, try to determine specific distribution
36
37
unset UNAME
37
38
DISTRO=$( echo $DISTRO | tr " [:lower:]" " [:upper:]" )
38
39
TMPDIR=/tmp
40
+ TF_VERSION=" 1.4.0"
41
+ TF_TYPE=" cpu"
42
+
43
+
44
+ function install_protobuf3.4.0() {
45
+ # Install Relevant tooling
46
+ # Remove any old versions of protobuf
47
+ DISTRIB=$1 # ubuntu/fedora
48
+ if [ " $DISTRIB " == " ubuntu" ]
49
+ then
50
+ sudo apt-get --yes --force-yes remove --purge libprotobuf-dev protobuf-compiler
51
+ elif [ " $DISTRIB " == " fedora" ]
52
+ then
53
+ sudo dnf -q remove -y protobuf protobuf-devel protobuf-compiler
54
+ else
55
+ echo " Only Ubuntu and Fedora is supported currently!"
56
+ return 0
57
+ fi
58
+ wget -O protobuf-cpp-3.4.0.tar.gz https://github.com/google/protobuf/releases/download/v3.4.0/protobuf-cpp-3.4.0.tar.gz
59
+ tar -xzf protobuf-cpp-3.4.0.tar.gz
60
+ cd protobuf-3.4.0
61
+ ./autogen.sh && ./configure && make -j4 && sudo make install && sudo ldconfig
62
+ cd ..
63
+ # Cleanup
64
+ rm -rf protobuf-3.4.0 protobuf-cpp-3.4.0.tar.gz
65
+ }
66
+
67
+ # Utility function for installing tensorflow components of python/C++
68
+ function install_tf() {
69
+ TFCApiFile=$1
70
+ TFBinaryURL=$2
71
+ LinkerConfigCmd=$3
72
+ TARGET_DIRECTORY=" /usr/local"
73
+ # Install Tensorflow Python Binary
74
+ sudo -E pip3 install --upgrade ${TFBinaryURL}
75
+
76
+ # Install C-API
77
+ TFCApiURL=" https://storage.googleapis.com/tensorflow/libtensorflow/${TFCApiFile} "
78
+ wget -O $TFCApiFile $TFCApiURL
79
+ sudo tar -C $TARGET_DIRECTORY -xzf $TFCApiFile || true
80
+ # Configure the Linker
81
+ eval $LinkerConfigCmd
82
+ # Cleanup
83
+ rm -rf ${TFCApiFile}
84
+ }
39
85
40
86
# # ------------------------------------------------
41
87
# # UBUNTU
@@ -75,13 +121,19 @@ if [ "$DISTRO" = "UBUNTU" ]; then
75
121
if [ " $MAJOR_VER " == " 14" ]; then
76
122
PKG_CMAKE=" cmake3"
77
123
FORCE_Y=" --force-yes"
124
+ TFBinaryURL=" https://storage.googleapis.com/tensorflow/linux/${TF_TYPE} /tensorflow-${TF_VERSION} -cp34-cp34m-linux_x86_64.whl"
125
+ fi
126
+ if [ " $MAJOR_VER " == " 16" ]; then
127
+ TFBinaryURL=" https://storage.googleapis.com/tensorflow/linux/${TF_TYPE} /tensorflow-${TF_VERSION} -cp35-cp35m-linux_x86_64.whl"
78
128
fi
79
129
# Fix for llvm on Ubuntu 17.x
80
130
if [ " $MAJOR_VER " == " 17" ]; then
81
131
PKG_LLVM=" llvm-3.9"
82
132
PKG_CLANG=" clang-3.8"
133
+ TFBinaryURL=" https://storage.googleapis.com/tensorflow/linux/${TF_TYPE} /tensorflow-${TF_VERSION} -cp35-cp35m-linux_x86_64.whl"
83
134
fi
84
-
135
+ TFCApiFile=" libtensorflow-${TF_TYPE} -linux-x86_64-${TF_VERSION} .tar.gz"
136
+ LinkerConfigCmd=" sudo ldconfig"
85
137
sudo apt-get -qq $FORCE_Y --ignore-missing -y install \
86
138
$PKG_CMAKE \
87
139
$PKG_LLVM \
@@ -92,9 +144,7 @@ if [ "$DISTRO" = "UBUNTU" ]; then
92
144
flex \
93
145
valgrind \
94
146
lcov \
95
- protobuf-compiler \
96
147
libgflags-dev \
97
- libprotobuf-dev \
98
148
libevent-dev \
99
149
libboost-dev \
100
150
libboost-thread-dev \
@@ -103,7 +153,19 @@ if [ "$DISTRO" = "UBUNTU" ]; then
103
153
libpqxx-dev \
104
154
libedit-dev \
105
155
libssl-dev \
106
- postgresql-client
156
+ postgresql-client \
157
+ python3-pip \
158
+ curl \
159
+ autoconf \
160
+ automake \
161
+ libtool \
162
+ make \
163
+ g++ \
164
+ unzip
165
+ # Install version of protobuf needed by C-API
166
+ install_protobuf3.4.0 " ubuntu"
167
+ # Install tensorflow
168
+ install_tf " $TFCApiFile " " $TFBinaryURL " " $LinkerConfigCmd "
107
169
108
170
# # ------------------------------------------------
109
171
# # DEBIAN
@@ -140,14 +202,15 @@ elif [[ "$DISTRO" == *"FEDORA"* ]]; then
140
202
26) LLVM=" llvm" ;;
141
203
* ) LLVM=" llvm4.0" ;;
142
204
esac
143
-
205
+ TFCApiFile=" libtensorflow-${TF_TYPE} -linux-x86_64-${TF_VERSION} .tar.gz"
206
+ TFBinaryURL=" https://storage.googleapis.com/tensorflow/linux/${TF_TYPE} /tensorflow-${TF_VERSION} -cp36-cp36m-linux_x86_64.whl"
207
+ LinkerConfigCmd=" sudo ldconfig"
144
208
sudo dnf -q install -y \
145
209
git \
146
210
gcc-c++ \
147
211
make \
148
212
cmake \
149
213
gflags-devel \
150
- protobuf-devel \
151
214
bison \
152
215
flex \
153
216
libevent-devel \
@@ -166,7 +229,16 @@ elif [[ "$DISTRO" == *"FEDORA"* ]]; then
166
229
libasan \
167
230
libtsan \
168
231
libubsan \
169
- libatomic
232
+ libatomic \
233
+ python3-pip \
234
+ curl \
235
+ autoconf \
236
+ automake \
237
+ libtool
238
+ # Install version of protobuf needed by C-API
239
+ install_protobuf3.4.0 " fedora"
240
+ # Install tensorflow
241
+ install_tf " $TFCApiFile " " $TFBinaryURL " " $LinkerConfigCmd "
170
242
171
243
# # ------------------------------------------------
172
244
# # REDHAT
@@ -194,18 +266,17 @@ elif [[ "$DISTRO" == *"REDHAT"* ]] && [[ "${DISTRO_VER%.*}" == "7" ]]; then
194
266
fi
195
267
popd ; popd
196
268
return 0
197
- }
269
+ }
198
270
199
- # Package download paths
271
+ # Package download paths
200
272
PKGS=(
201
273
" https://github.com/schuhschuh/gflags/archive/v2.0.tar.gz"
202
274
)
203
-
204
- # Add EPEL repository first
275
+ # Add EPEL repository first
205
276
sudo yum -q -y install epel-release
206
277
sudo yum -q -y upgrade epel-release
207
278
208
- # Simple installations via yum
279
+ # Simple installations via yum
209
280
sudo yum -q -y install \
210
281
git \
211
282
gcc-c++ \
@@ -245,7 +316,9 @@ elif [ "$DISTRO" = "DARWIN" ]; then
245
316
echo " Installing homebrew..."
246
317
ruby -e " $( curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install) "
247
318
fi
248
-
319
+ TFBinaryURL=" https://storage.googleapis.com/tensorflow/mac/${TF_TYPE} /tensorflow-${TF_VERSION} -py3-none-any.whl"
320
+ TFCApiFile=" libtensorflow-${TF_TYPE} -darwin-x86_64-${TF_VERSION} .tar.gz"
321
+ LinkerConfigCmd=" sudo update_dyld_shared_cache"
249
322
brew install git
250
323
brew install cmake
251
324
brew install gflags
@@ -260,6 +333,13 @@ elif [ "$DISTRO" = "DARWIN" ]; then
260
333
brew install libedit
261
334
262
335
brew install postgresql
336
+ brew install curl
337
+ brew install wget
338
+ brew install python
339
+ brew upgrade python
340
+ # Brew installs correct version of Protobuf(3.5.1 >= 3.4.0)
341
+ # So we can directly install tensorflow
342
+ install_tf " $TFCApiFile " " $TFBinaryURL " " $LinkerConfigCmd "
263
343
264
344
# # ------------------------------------------------
265
345
# # UNKNOWN
0 commit comments