forked from tensorflow/tensorflow
-
Notifications
You must be signed in to change notification settings - Fork 25
/
tc-build.sh
executable file
·107 lines (89 loc) · 4.1 KB
/
tc-build.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
#!/bin/bash
set -ex
source $(dirname $0)/tc-vars.sh
build_amd64=yes
build_cuda=no
build_android_arm=no
build_android_arm64=no
build_linux_arm=no
build_linux_arm64=no
if [ "$1" = "--cuda" ]; then
build_amd64=yes
build_cuda=yes
build_android_arm=no
build_android_arm64=no
build_linux_arm=no
build_linux_arm64=no
fi
if [ "$1" = "--arm" ]; then
build_amd64=yes
build_cuda=no
build_android_arm=no
build_android_arm64=no
build_linux_arm=yes
build_linux_arm64=no
fi
if [ "$1" = "--arm64" ]; then
build_amd64=yes
build_cuda=no
build_android_arm=no
build_android_arm64=no
build_linux_arm=no
build_linux_arm64=yes
fi
if [ "$1" = "--android-armv7" ]; then
build_amd64=no
build_cuda=no
build_android_arm=yes
build_android_arm64=no
build_linux_arm=no
build_linux_arm64=no
fi
if [ "$1" = "--android-arm64" ]; then
build_amd64=no
build_cuda=no
build_android_arm=no
build_android_arm64=yes
build_linux_arm=no
build_linux_arm64=no
fi
pushd ${DS_ROOT_TASK}/DeepSpeech/tf/
BAZEL_BUILD="bazel ${BAZEL_OUTPUT_USER_ROOT} build -s --explain bazel_monolithic_tf.log --verbose_explanations --experimental_strict_action_env --config=monolithic"
# Start a bazel process to ensure reliability on Windows and avoid:
# FATAL: corrupt installation: file 'c:\builds\tc-workdir\.bazel_cache/install/6b1660721930e9d5f231f7d2a626209b/_embedded_binaries/build-runfiles.exe' missing.
bazel ${BAZEL_OUTPUT_USER_ROOT} info
if [ "${build_amd64}" = "yes" ]; then
# Pure amd64 CPU-only build
if [ "${OS}" = "${TC_MSYS_VERSION}" -a "${build_cuda}" = "no" ]; then
echo "" | TF_NEED_CUDA=0 ./configure && ${BAZEL_BUILD} -c opt ${BAZEL_OPT_FLAGS} ${BAZEL_EXTRA_FLAGS} ${BUILD_TARGET_LIB_CPP_API} ${BUILD_TARGET_GRAPH_TRANSFORMS} ${BUILD_TARGET_GRAPH_SUMMARIZE} ${BUILD_TARGET_GRAPH_BENCHMARK} ${BUILD_TARGET_CONVERT_MMAP} ${BUILD_TARGET_TOCO}
else
if [ "${build_cuda}" = "no" -a "${build_linux_arm}" = "no" -a "${build_linux_arm64}" = "no" ]; then
echo "" | TF_NEED_CUDA=0 ./configure && ${BAZEL_BUILD} -c opt ${BAZEL_OPT_FLAGS} ${BAZEL_EXTRA_FLAGS} ${BUILD_TARGET_LIB_CPP_API} ${BUILD_TARGET_GRAPH_TRANSFORMS} ${BUILD_TARGET_GRAPH_SUMMARIZE} ${BUILD_TARGET_GRAPH_BENCHMARK} ${BUILD_TARGET_CONVERT_MMAP} ${BUILD_TARGET_TOCO} ${BUILD_TARGET_LITE_BENCHMARK}
fi
fi
# Cross RPi3 CPU-only build
if [ "${build_linux_arm}" = "yes" ]; then
echo "" | TF_NEED_CUDA=0 ./configure && ${BAZEL_BUILD} -c opt ${BAZEL_ARM_FLAGS} ${BAZEL_EXTRA_FLAGS} ${BUILD_TARGET_LIB_CPP_API} ${BUILD_TARGET_GRAPH_TRANSFORMS} ${BUILD_TARGET_GRAPH_SUMMARIZE} ${BUILD_TARGET_GRAPH_BENCHMARK}
fi
# Cross ARM64 Cortex-A53 build
if [ "${build_linux_arm64}" = "yes" ]; then
echo "" | TF_NEED_CUDA=0 ./configure && ${BAZEL_BUILD} -c opt ${BAZEL_ARM64_FLAGS} ${BAZEL_EXTRA_FLAGS} ${BUILD_TARGET_LIB_CPP_API} ${BUILD_TARGET_GRAPH_TRANSFORMS} ${BUILD_TARGET_GRAPH_SUMMARIZE} ${BUILD_TARGET_GRAPH_BENCHMARK}
fi
# Pure amd64 GPU-enabled build
if [ "${build_cuda}" = "yes" ]; then
eval "export ${TF_CUDA_FLAGS}" && (echo "" | TF_NEED_CUDA=1 ./configure) && ${BAZEL_BUILD} -c opt ${BAZEL_CUDA_FLAGS} ${BAZEL_EXTRA_FLAGS} ${BAZEL_OPT_FLAGS} ${BUILD_TARGET_LIB_CPP_API} ${BUILD_TARGET_GRAPH_TRANSFORMS} ${BUILD_TARGET_GRAPH_SUMMARIZE} ${BUILD_TARGET_GRAPH_BENCHMARK}
fi
fi
if [ "${build_android_arm}" = "yes" ]; then
echo "" | TF_SET_ANDROID_WORKSPACE=1 ./configure && ${BAZEL_BUILD} -c opt ${BAZEL_ANDROID_ARM_FLAGS} ${BAZEL_EXTRA_FLAGS} ${BUILD_TARGET_LITE_LIB}
fi;
if [ "${build_android_arm64}" = "yes" ]; then
echo "" | TF_SET_ANDROID_WORKSPACE=1 ./configure && ${BAZEL_BUILD} -c opt ${BAZEL_ANDROID_ARM64_FLAGS} ${BAZEL_EXTRA_FLAGS} ${BUILD_TARGET_LITE_LIB}
fi;
if [ $? -ne 0 ]; then
# There was a failure, just account for it.
echo "Build failure, please check the output above. Exit code was: $?"
return 1
fi
bazel ${BAZEL_OUTPUT_USER_ROOT} shutdown
popd