forked from waymo-research/waymo-open-dataset
-
Notifications
You must be signed in to change notification settings - Fork 0
/
configure.sh
executable file
·62 lines (55 loc) · 2.32 KB
/
configure.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
#!/bin/bash
# Copyright 2019 The Waymo Open Dataset Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# ==============================================================================
# This file is modified from configure.sh in
# https://github.com/tensorflow/custom-op.
# This script writes to .bazelrc to tensorflow libs.
function write_to_bazelrc() {
echo "$1" >> .bazelrc
}
function write_action_env_to_bazelrc() {
write_to_bazelrc "build --action_env $1=\"$2\""
}
# Remove .bazelrc if it already exist
[ -e .bazelrc ] && rm .bazelrc
write_to_bazelrc "build -c opt"
write_to_bazelrc 'build --cxxopt="-std=c++11"'
write_to_bazelrc 'build --cxxopt="-D_GLIBCXX_USE_CXX11_ABI=0"'
write_to_bazelrc 'build --auto_output_filter=subpackages'
write_to_bazelrc 'build --copt="-Wall" --copt="-Wno-sign-compare"'
TF_NEED_CUDA=0
# Check if it's installed
TF_CFLAGS=""
TF_LFLAGS=""
if [[ $(pip3 show tensorflow) == *tensorflow* ]] || [[ $(pip3 show tf-nightly) == *tf-nightly* ]] ; then
echo 'Using installed tensorflow'
TF_CFLAGS=( $(python3 -c 'import tensorflow as tf; print(" ".join(tf.sysconfig.get_compile_flags()))') )
TF_LFLAGS="$(python3 -c 'import tensorflow as tf; print(" ".join(tf.sysconfig.get_link_flags()))')"
else
echo 'CPU Tensorflow is not installed'
fi
write_action_env_to_bazelrc "TF_HEADER_DIR" ${TF_CFLAGS:2}
SHARED_LIBRARY_DIR=${TF_LFLAGS:2}
SHARED_LIBRARY_NAME=$(echo $TF_LFLAGS | rev | cut -d":" -f1 | rev)
if ! [[ $TF_LFLAGS =~ .*:.* ]]; then
if [[ "$(uname)" == "Darwin" ]]; then
SHARED_LIBRARY_NAME="libtensorflow_framework.dylib"
else
SHARED_LIBRARY_NAME="libtensorflow_framework.so"
fi
fi
write_action_env_to_bazelrc "TF_SHARED_LIBRARY_DIR" ${SHARED_LIBRARY_DIR}
write_action_env_to_bazelrc "TF_SHARED_LIBRARY_NAME" ${SHARED_LIBRARY_NAME}
write_action_env_to_bazelrc "TF_NEED_CUDA" ${TF_NEED_CUDA}