aboutsummaryrefslogtreecommitdiffhomepage
path: root/configure
diff options
context:
space:
mode:
authorGravatar A. Unique TensorFlower <gardener@tensorflow.org>2017-03-30 07:38:55 -0800
committerGravatar TensorFlower Gardener <gardener@tensorflow.org>2017-03-30 08:54:57 -0700
commit8d393ea2fab0ea88ecd11e36d89f186cbc884dbe (patch)
treecf7696a2e7afb85a1283502f589cfeecc8538417 /configure
parent6e5f92ffc743c9b1765ffe4b79aac29a7059d464 (diff)
Add cuda_clang build configuration that allows to use clang as a CUDA compiler.
Change: 151705528
Diffstat (limited to 'configure')
-rwxr-xr-xconfigure65
1 files changed, 61 insertions, 4 deletions
diff --git a/configure b/configure
index 081db20d75..e59ee2a925 100755
--- a/configure
+++ b/configure
@@ -38,7 +38,7 @@ function is_windows() {
fi
}
-function bazel_clean_and_fetch() {
+function bazel_fetch() {
if [ -z "$TF_BAZEL_TARGETS" ]; then
bazel fetch "//tensorflow/... -//tensorflow/contrib/nccl/... -//tensorflow/examples/android/..."
else
@@ -279,18 +279,40 @@ while [ "$TF_NEED_CUDA" == "" ]; do
esac
done
+sed_hyphen_i -e "/--action_env TF_NEED_CUDA/d" .bazelrc
+sed_hyphen_i -e "/--action_env CUD/d" .bazelrc
+sed_hyphen_i -e "/--action_env GCC_HOST/d" .bazelrc
+sed_hyphen_i -e "/--action_env TF_CUD/d" .bazelrc
+sed_hyphen_i -e "/--action_env CLANG_CUDA/d" .bazelrc
+
export TF_NEED_CUDA
+echo "build --action_env TF_NEED_CUDA=$TF_NEED_CUDA" >>.bazelrc
+
export TF_NEED_OPENCL
+
if [[ "$TF_NEED_CUDA" == "0" ]] && [[ "$TF_NEED_OPENCL" == "0" ]]; then
echo "Configuration finished"
- bazel_clean_and_fetch
+ bazel_fetch
exit
fi
if [ "$TF_NEED_CUDA" == "1" ]; then
+while [[ "$TF_CUDA_CLANG" == "" ]]; do
+ read -p "Do you want to use clang as CUDA compiler? [y/N] " INPUT
+ case $INPUT in
+ [Yy]* ) echo "Clang will be used as CUDA compiler"; TF_CUDA_CLANG=1;;
+ [Nn]* ) echo "nvcc will be used as CUDA compiler"; TF_CUDA_CLANG=0;;
+ "" ) echo "nvcc will be used as CUDA compiler"; TF_CUDA_CLANG=0;;
+ * ) echo "Invalid selection: " $INPUT;;
+ esac
+done
+
+export TF_CUDA_CLANG
+echo "build --action_env TF_CUDA_CLANG=$TF_CUDA_CLANG" >>.bazelrc
+
# Set up which gcc nvcc should use as the host compiler
# No need to set this on Windows
-while ! is_windows && true; do
+while [[ "$TF_CUDA_CLANG" != "1" ]] && ! is_windows && true; do
fromuser=""
if [ -z "$GCC_HOST_COMPILER_PATH" ]; then
default_gcc_host_compiler_path=$(which gcc || true)
@@ -302,6 +324,7 @@ while ! is_windows && true; do
fi
if [ -e "$GCC_HOST_COMPILER_PATH" ]; then
export GCC_HOST_COMPILER_PATH
+ echo "build --action_env GCC_HOST_COMPILER_PATH=\"$GCC_HOST_COMPILER_PATH\"" >>.bazelrc
break
fi
echo "Invalid gcc path. ${GCC_HOST_COMPILER_PATH} cannot be found" 1>&2
@@ -312,6 +335,30 @@ while ! is_windows && true; do
# Retry
done
+# Set up which clang we should use as the cuda / host compiler.
+while [[ "$TF_CUDA_CLANG" == "1" ]] && true; do
+ fromuser=""
+ if [ -z "$CLANG_CUDA_COMPILER_PATH" ]; then
+ default_clang_host_compiler_path=$(which clang || true)
+ read -p "Please specify which clang should be used as device and host compiler. [Default is $default_clang_host_compiler_path]: " CLANG_CUDA_COMPILER_PATH
+ fromuser="1"
+ if [ -z "$CLANG_CUDA_COMPILER_PATH" ]; then
+ CLANG_CUDA_COMPILER_PATH="$default_clang_host_compiler_path"
+ fi
+ fi
+ if [ -e "$CLANG_CUDA_COMPILER_PATH" ]; then
+ export CLANG_CUDA_COMPILER_PATH
+ echo "build --action_env CLANG_CUDA_COMPILER_PATH=\"$CLANG_CUDA_COMPILER_PATH\"" >>.bazelrc
+ break
+ fi
+ echo "Invalid clang path. ${CLANG_CUDA_COMPILER_PATH} cannot be found" 1>&2
+ if [ -z "$fromuser" ]; then
+ exit 1
+ fi
+ CLANG_CUDA_COMPILER_PATH=""
+ # Retry
+done
+
# Find out where the CUDA toolkit is installed
while true; do
# Configure the Cuda SDK version to use.
@@ -352,7 +399,10 @@ while true; do
if [ -e "${CUDA_TOOLKIT_PATH}/${CUDA_RT_LIB_PATH}" ]; then
export CUDA_TOOLKIT_PATH
+ echo "build --action_env CUDA_TOOLKIT_PATH=\"$CUDA_TOOLKIT_PATH\"" >>.bazelrc
+
export TF_CUDA_VERSION
+ echo "build --action_env TF_CUDA_VERSION=$TF_CUDA_VERSION" >>.bazelrc
break
fi
echo "Invalid path to CUDA $TF_CUDA_VERSION toolkit. ${CUDA_TOOLKIT_PATH}/${CUDA_RT_LIB_PATH} cannot be found"
@@ -404,7 +454,10 @@ while true; do
if [ -e "$CUDNN_INSTALL_PATH/${CUDA_DNN_LIB_ALT_PATH}" -o -e "$CUDNN_INSTALL_PATH/${CUDA_DNN_LIB_PATH}" ]; then
export TF_CUDNN_VERSION
+ echo "build --action_env TF_CUDNN_VERSION=$TF_CUDNN_VERSION" >>.bazelrc
+
export CUDNN_INSTALL_PATH
+ echo "build --action_env CUDNN_INSTALL_PATH=\"$CUDNN_INSTALL_PATH\"" >>.bazelrc
break
fi
@@ -417,7 +470,10 @@ while true; do
CUDNN_PATH_FROM_LDCONFIG="$($LDCONFIG_BIN -p | sed -n 's/.*libcudnn.so .* => \(.*\)/\1/p')"
if [ -e "${CUDNN_PATH_FROM_LDCONFIG}${TF_CUDNN_EXT}" ]; then
export TF_CUDNN_VERSION
+ echo "build --action_env TF_CUDNN_VERSION=$TF_CUDNN_VERSION" >>.bazelrc
+
export CUDNN_INSTALL_PATH="$(dirname ${CUDNN_PATH_FROM_LDCONFIG})"
+ echo "build --action_env CUDNN_INSTALL_PATH=\"$CUDNN_INSTALL_PATH\"" >>.bazelrc
break
fi
fi
@@ -469,6 +525,7 @@ EOF
fi
else
export TF_CUDA_COMPUTE_CAPABILITIES
+ echo "build --action_env TF_CUDA_COMPUTE_CAPABILITIES=$TF_CUDA_COMPUTE_CAPABILITIES" >>.bazelrc
break
fi
TF_CUDA_COMPUTE_CAPABILITIES=""
@@ -572,6 +629,6 @@ done
# end of if "$TF_NEED_OPENCL" == "1"
fi
-bazel_clean_and_fetch
+bazel_fetch
echo "Configuration finished"