-
Notifications
You must be signed in to change notification settings - Fork 3
/
tensorflowBuild.sh
executable file
·86 lines (61 loc) · 2.31 KB
/
tensorflowBuild.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
#!/bin/bash
#Script last updated 23-06-2020
#Get number of bytes in RAM
RAM=`free | grep Mem | tr -s ' '| cut -f2 -d ' '`
BazelPleaseSlowDown="--local_resources 2048,.5,1.0"
if [ "$RAM" -gt "11286464" ]; then
echo "More than 12GB";
BazelPleaseSlowDown=" "
fi
if [ "$RAM" -gt "15297500" ]; then
echo "More than 16GB";
BazelPleaseSlowDown=" "
fi
if [ "$RAM" -gt "31861780" ]; then
echo "More than 32GB";
BazelPleaseSlowDown=" "
fi
#Tensorflow is a great Neural network library that unfortunately is coupled to the terrible Bazel build system
#This is a download and build script for Ubuntu 18.04, that should work building release 1.15
sudo apt-get install python3-dev python3-pip python3-venv python3-tk
pip install -U --user pip six numpy wheel setuptools mock 'future>=0.17.1'
pip install -U --user keras_applications --no-deps
pip install -U --user keras_preprocessing --no-deps
cd ~/Documents
mkdir 3dParty
cd 3dParty
wget http://ammar.gr/mocapnet/bazel-0.24.1-installer-linux-x86_64-for-tensorflow-r1.15.sh
chmod +x bazel-0.24.1-installer-linux-x86_64-for-tensorflow-r1.15.sh
./bazel-0.24.1-installer-linux-x86_64-for-tensorflow-r1.15.sh --user
#Create shared directory
if [ -f ~/.bashrc ]
then
if cat ~/.bashrc | grep -q "BAZEL_CANCER"
then
echo "Bazel includes seem to be set-up.."
else
USER=`whoami`
echo "#BAZEL_CANCER" >> ~/.bashrc
echo "source ~/.bazel/bin/bazel-complete.bash" >> ~/.bashrc
echo "export PATH=\"\$PATH:\$HOME/bin\"" >> ~/.bashrc
source ~/.bashrc
fi
fi
if [ ! -d tensorflow ]
then
git clone https://github.com/tensorflow/tensorflow.git
fi
cd tensorflow
git pull
git checkout r1.15
./configure
bazel clean --expunge
#Flags for bazel if you have gcc<5.0
#--cxxopt="-D_GLIBCXX_USE_CXX11_ABI=0"
#--noincompatible_do_not_split_linking_cmdline
bazel build --config=opt --config=cuda --config=mkl --config=monolithic $BazelPleaseSlowDown //tensorflow/tools/pip_package:build_pip_package
./bazel-bin/tensorflow/tools/pip_package/build_pip_package ~/Documents/3dParty/
bazel build --config opt --config=cuda --config=monolithic //tensorflow/tools/lib_package:libtensorflow
mv bazel-bin/tensorflow/tools/lib_package/libtensorflow.tar.gz ~/Documents/3dParty/libtensorflow-r1.15.tar.gz
echo "Please visit ~/Documents/3dParty/ to collect your tensorflow python3 wheel, and C Library.."
exit 0