Geoffrey Irving | 4c85a08 | 2016-03-16 12:20:34 -0800 | [diff] [blame] | 1 | #!/usr/bin/env bash |
Manjunath Kudlur | f41959c | 2015-11-06 16:27:58 -0800 | [diff] [blame] | 2 | |
A. Unique TensorFlower | edaf3b3 | 2016-10-10 10:26:22 -0800 | [diff] [blame] | 3 | set -e |
| 4 | set -o pipefail |
| 5 | |
Andrew Selle | 09045e4 | 2016-09-06 08:19:04 -0800 | [diff] [blame] | 6 | # Find out the absolute path to where ./configure resides |
A. Unique TensorFlower | 46d2c28 | 2017-01-02 22:19:48 -0800 | [diff] [blame] | 7 | pushd `dirname $0` > /dev/null |
Andrew Selle | 09045e4 | 2016-09-06 08:19:04 -0800 | [diff] [blame] | 8 | SOURCE_BASE_DIR=`pwd -P` |
| 9 | popd > /dev/null |
| 10 | |
Patrick Nguyen | c5ab3dd | 2016-10-20 12:09:18 -0800 | [diff] [blame] | 11 | PLATFORM="$(uname -s | tr 'A-Z' 'a-z')" |
Jonathan Hseu | c058a01 | 2017-01-17 15:06:43 -0800 | [diff] [blame] | 12 | |
| 13 | function is_linux() { |
| 14 | if [[ "${PLATFORM}" == "linux" ]]; then |
| 15 | true |
| 16 | else |
| 17 | false |
| 18 | fi |
| 19 | } |
| 20 | |
| 21 | function is_macos() { |
| 22 | if [[ "${PLATFORM}" == "darwin" ]]; then |
| 23 | true |
| 24 | else |
| 25 | false |
| 26 | fi |
| 27 | } |
| 28 | |
Patrick Nguyen | c5ab3dd | 2016-10-20 12:09:18 -0800 | [diff] [blame] | 29 | function is_windows() { |
| 30 | # On windows, the shell script is actually running in msys |
Shanqing Cai | 56fc883 | 2017-01-23 18:25:25 -0800 | [diff] [blame] | 31 | if [[ "${PLATFORM}" =~ msys_nt*|mingw*|cygwin*|uwin* ]]; then |
Patrick Nguyen | c5ab3dd | 2016-10-20 12:09:18 -0800 | [diff] [blame] | 32 | true |
| 33 | else |
| 34 | false |
| 35 | fi |
| 36 | } |
| 37 | |
Jonathan Hseu | 1283b84 | 2016-09-29 15:05:32 -0800 | [diff] [blame] | 38 | function bazel_clean_and_fetch() { |
Patrick Nguyen | c5ab3dd | 2016-10-20 12:09:18 -0800 | [diff] [blame] | 39 | # bazel clean --expunge currently doesn't work on Windows |
| 40 | # TODO(pcloudy): Re-enable it after bazel clean --expunge is fixed. |
| 41 | if ! is_windows; then |
| 42 | bazel clean --expunge |
| 43 | fi |
Asim Shankar | 429d14d | 2017-03-13 13:27:31 -0800 | [diff] [blame] | 44 | if [ -z "$TF_BAZEL_TARGETS" ]; then |
| 45 | TF_BAZEL_TARGETS="//tensorflow/... -//tensorflow/contrib/nccl/... -//tensorflow/examples/android/..." |
| 46 | fi |
| 47 | bazel fetch "$TF_BAZEL_TARGETS" |
Jonathan Hseu | 1283b84 | 2016-09-29 15:05:32 -0800 | [diff] [blame] | 48 | } |
| 49 | |
Dandelion Mané | 0386a01 | 2017-03-10 14:43:23 -0800 | [diff] [blame] | 50 | function sed_hyphen_i() { |
| 51 | if is_macos; then |
| 52 | sed -i '' "$@" |
| 53 | else |
| 54 | sed -i "$@" |
| 55 | fi |
| 56 | } |
| 57 | |
Andrew Harp | 51dbc46 | 2017-01-27 14:42:30 -0800 | [diff] [blame] | 58 | # Delete any leftover BUILD files from the Makefile build, which would interfere |
| 59 | # with Bazel parsing. |
| 60 | MAKEFILE_DOWNLOAD_DIR=tensorflow/contrib/makefile/downloads |
| 61 | if [ -d "${MAKEFILE_DOWNLOAD_DIR}" ]; then |
| 62 | find ${MAKEFILE_DOWNLOAD_DIR} -type f -name '*BUILD' -delete |
| 63 | fi |
| 64 | |
Vijay Vasudevan | bf6b536 | 2015-12-02 15:04:40 -0800 | [diff] [blame] | 65 | ## Set up python-related environment settings |
| 66 | while true; do |
| 67 | fromuser="" |
| 68 | if [ -z "$PYTHON_BIN_PATH" ]; then |
A. Unique TensorFlower | edaf3b3 | 2016-10-10 10:26:22 -0800 | [diff] [blame] | 69 | default_python_bin_path=$(which python || which python3 || true) |
Vijay Vasudevan | bf6b536 | 2015-12-02 15:04:40 -0800 | [diff] [blame] | 70 | read -p "Please specify the location of python. [Default is $default_python_bin_path]: " PYTHON_BIN_PATH |
| 71 | fromuser="1" |
| 72 | if [ -z "$PYTHON_BIN_PATH" ]; then |
| 73 | PYTHON_BIN_PATH=$default_python_bin_path |
| 74 | fi |
| 75 | fi |
| 76 | if [ -e "$PYTHON_BIN_PATH" ]; then |
| 77 | break |
| 78 | fi |
| 79 | echo "Invalid python path. ${PYTHON_BIN_PATH} cannot be found" 1>&2 |
| 80 | if [ -z "$fromuser" ]; then |
| 81 | exit 1 |
| 82 | fi |
| 83 | PYTHON_BIN_PATH="" |
| 84 | # Retry |
| 85 | done |
| 86 | |
Benoit Steiner | 639b4e7 | 2017-02-08 09:25:09 -0800 | [diff] [blame] | 87 | ## Set up MKL related environment settings |
| 88 | if false; then # Disable building with MKL for now |
| 89 | while [ "$TF_NEED_MKL" == "" ]; do |
| 90 | fromuser="" |
| 91 | read -p "Do you wish to build TensorFlow with MKL support? [y/N] " INPUT |
| 92 | fromuser="1" |
| 93 | case $INPUT in |
| 94 | [Yy]* ) echo "MKL support will be enabled for TensorFlow"; TF_NEED_MKL=1;; |
| 95 | [Nn]* ) echo "No MKL support will be enabled for TensorFlow"; TF_NEED_MKL=0;; |
| 96 | "" ) echo "No MKL support will be enabled for TensorFlow"; TF_NEED_MKL=0;; |
| 97 | * ) echo "Invalid selection: " $INPUT;; |
| 98 | esac |
| 99 | done |
| 100 | |
| 101 | OSNAME=`uname -s` |
| 102 | |
| 103 | if [ "$TF_NEED_MKL" == "1" ]; then # TF_NEED_MKL |
| 104 | DST=`dirname $0` |
| 105 | ARCHIVE_BASENAME=mklml_lnx_2017.0.2.20170110.tgz |
| 106 | GITHUB_RELEASE_TAG=v0.3 |
| 107 | MKLURL="https://github.com/01org/mkl-dnn/releases/download/$GITHUB_RELEASE_TAG/$ARCHIVE_BASENAME" |
| 108 | if ! [ -e "$DST/third_party/mkl/$ARCHIVE_BASENAME" ]; then |
| 109 | wget --no-check-certificate -P $DST/third_party/mkl/ $MKLURL |
| 110 | fi |
| 111 | tar -xzf $DST/third_party/mkl/$ARCHIVE_BASENAME -C $DST/third_party/mkl/ |
| 112 | extracted_dir_name="${ARCHIVE_BASENAME%.*}" |
| 113 | MKL_INSTALL_PATH=$DST/third_party/mkl/$extracted_dir_name |
| 114 | MKL_INSTALL_PATH=`${PYTHON_BIN_PATH} -c "import os; print(os.path.realpath(os.path.expanduser('${MKL_INSTALL_PATH}')))"` |
| 115 | |
| 116 | if [ "$OSNAME" == "Linux" ]; then |
| 117 | # Full MKL configuration |
| 118 | MKL_RT_LIB_PATH="lib/intel64/libmkl_rt.so" #${TF_MKL_EXT}#TODO version? |
| 119 | MKL_RT_OMP_LIB_PATH="../compiler/lib/intel64/libiomp5.so" #TODO VERSION? |
| 120 | |
| 121 | # MKL-ML configuration |
| 122 | MKL_ML_LIB_PATH="lib/libmklml_intel.so" #${TF_MKL_EXT}#TODO version? |
| 123 | MKL_ML_OMP_LIB_PATH="lib/libiomp5.so" #TODO VERSION? |
| 124 | elif [ "$OSNAME" == "Darwin" ]; then |
| 125 | echo "Darwin is unsupported yet"; |
| 126 | exit 1 |
| 127 | fi |
| 128 | |
| 129 | if [ -e "$MKL_INSTALL_PATH/${MKL_ML_LIB_PATH}" ]; then |
| 130 | ln -sf $MKL_INSTALL_PATH/${MKL_ML_LIB_PATH} third_party/mkl/ |
| 131 | ln -sf $MKL_INSTALL_PATH/${MKL_ML_OMP_LIB_PATH} third_party/mkl/ |
| 132 | ln -sf $MKL_INSTALL_PATH/include third_party/mkl/ |
| 133 | ln -sf $MKL_INSTALL_PATH/include third_party/eigen3/mkl_include |
| 134 | else |
| 135 | echo "ERROR: $MKL_INSTALL_PATH/${MKL_ML_LIB_PATH} does not exist"; |
| 136 | exit 1 |
| 137 | fi |
| 138 | |
| 139 | if [ -z "$fromuser" ]; then |
| 140 | exit 1 |
| 141 | fi |
| 142 | |
| 143 | cat > third_party/mkl/mkl.config <<EOF |
| 144 | # MKL_INSTALL_PATH refers to the location of MKL root folder. The MKL header and library |
| 145 | # files can be either in this directory, or under include/ and lib64/ |
| 146 | MKL_INSTALL_PATH=$MKL_INSTALL_PATH |
| 147 | EOF |
| 148 | |
| 149 | fi # TF_NEED_MKL |
| 150 | ################## MKL |
| 151 | fi # Disable building with MKL for now |
| 152 | |
Martin Wicke | c4e3d4a | 2017-01-13 12:20:42 -0800 | [diff] [blame] | 153 | ## Set up architecture-dependent optimization flags. |
| 154 | if [ -z "$CC_OPT_FLAGS" ]; then |
| 155 | default_cc_opt_flags="-march=native" |
Benoit Steiner | 639b4e7 | 2017-02-08 09:25:09 -0800 | [diff] [blame] | 156 | read -p "Please specify optimization flags to use during compilation when bazel option "\ |
| 157 | "\"--config=opt\" is specified [Default is $default_cc_opt_flags]: " CC_OPT_FLAGS |
Martin Wicke | c4e3d4a | 2017-01-13 12:20:42 -0800 | [diff] [blame] | 158 | if [ -z "$CC_OPT_FLAGS" ]; then |
| 159 | CC_OPT_FLAGS=$default_cc_opt_flags |
| 160 | fi |
| 161 | fi |
| 162 | |
Patrick Nguyen | c5ab3dd | 2016-10-20 12:09:18 -0800 | [diff] [blame] | 163 | if is_windows; then |
A. Unique TensorFlower | 95a954a | 2016-12-28 13:40:08 -0800 | [diff] [blame] | 164 | TF_NEED_GCP=0 |
Patrick Nguyen | c5ab3dd | 2016-10-20 12:09:18 -0800 | [diff] [blame] | 165 | TF_NEED_HDFS=0 |
Jonathan Hseu | 83c6e0c | 2017-01-11 16:39:35 -0800 | [diff] [blame] | 166 | TF_NEED_JEMALLOC=0 |
Benoit Steiner | a771598 | 2016-11-09 13:14:03 -0800 | [diff] [blame] | 167 | TF_NEED_OPENCL=0 |
Patrick Nguyen | c5ab3dd | 2016-10-20 12:09:18 -0800 | [diff] [blame] | 168 | fi |
| 169 | |
Jonathan Hseu | c058a01 | 2017-01-17 15:06:43 -0800 | [diff] [blame] | 170 | if is_linux; then |
| 171 | while [ "$TF_NEED_JEMALLOC" == "" ]; do |
| 172 | read -p "Do you wish to use jemalloc as the malloc implementation? [Y/n] "\ |
| 173 | INPUT |
| 174 | case $INPUT in |
| 175 | [Yy]* ) echo "jemalloc enabled"; TF_NEED_JEMALLOC=1;; |
| 176 | [Nn]* ) echo "jemalloc disabled"; TF_NEED_JEMALLOC=0;; |
| 177 | "" ) echo "jemalloc enabled"; TF_NEED_JEMALLOC=1;; |
| 178 | * ) echo "Invalid selection: " $INPUT;; |
| 179 | esac |
| 180 | done |
| 181 | else |
| 182 | TF_NEED_JEMALLOC=0 |
| 183 | fi |
Jonathan Hseu | 83c6e0c | 2017-01-11 16:39:35 -0800 | [diff] [blame] | 184 | |
| 185 | if [ "$TF_NEED_JEMALLOC" == "1" ]; then |
Dandelion Mané | 0386a01 | 2017-03-10 14:43:23 -0800 | [diff] [blame] | 186 | sed_hyphen_i -e "s/WITH_JEMALLOC = False/WITH_JEMALLOC = True/" tensorflow/core/platform/default/build_config.bzl |
Jonathan Hseu | 83c6e0c | 2017-01-11 16:39:35 -0800 | [diff] [blame] | 187 | else |
Dandelion Mané | 0386a01 | 2017-03-10 14:43:23 -0800 | [diff] [blame] | 188 | sed_hyphen_i -e "s/WITH_JEMALLOC = True/WITH_JEMALLOC = False/" tensorflow/core/platform/default/build_config.bzl |
Jonathan Hseu | 83c6e0c | 2017-01-11 16:39:35 -0800 | [diff] [blame] | 189 | fi |
| 190 | |
A. Unique TensorFlower | 95a954a | 2016-12-28 13:40:08 -0800 | [diff] [blame] | 191 | while [ "$TF_NEED_GCP" == "" ]; do |
| 192 | read -p "Do you wish to build TensorFlow with "\ |
| 193 | "Google Cloud Platform support? [y/N] " INPUT |
| 194 | case $INPUT in |
| 195 | [Yy]* ) echo "Google Cloud Platform support will be enabled for "\ |
| 196 | "TensorFlow"; TF_NEED_GCP=1;; |
| 197 | [Nn]* ) echo "No Google Cloud Platform support will be enabled for "\ |
| 198 | "TensorFlow"; TF_NEED_GCP=0;; |
| 199 | "" ) echo "No Google Cloud Platform support will be enabled for "\ |
| 200 | "TensorFlow"; TF_NEED_GCP=0;; |
| 201 | * ) echo "Invalid selection: " $INPUT;; |
| 202 | esac |
| 203 | done |
| 204 | |
| 205 | if [ "$TF_NEED_GCP" == "1" ]; then |
| 206 | ## Verify that libcurl header files are available. |
| 207 | # Only check Linux, since on MacOS the header files are installed with XCode. |
Jonathan Hseu | c058a01 | 2017-01-17 15:06:43 -0800 | [diff] [blame] | 208 | if is_linux && [[ ! -f "/usr/include/curl/curl.h" ]]; then |
A. Unique TensorFlower | 95a954a | 2016-12-28 13:40:08 -0800 | [diff] [blame] | 209 | echo "ERROR: It appears that the development version of libcurl is not "\ |
| 210 | "available. Please install the libcurl3-dev package." |
| 211 | exit 1 |
| 212 | fi |
| 213 | |
| 214 | # Update Bazel build configuration. |
Dandelion Mané | 0386a01 | 2017-03-10 14:43:23 -0800 | [diff] [blame] | 215 | sed_hyphen_i -e "s/WITH_GCP_SUPPORT = False/WITH_GCP_SUPPORT = True/" tensorflow/core/platform/default/build_config.bzl |
A. Unique TensorFlower | 95a954a | 2016-12-28 13:40:08 -0800 | [diff] [blame] | 216 | else |
| 217 | # Update Bazel build configuration. |
Dandelion Mané | 0386a01 | 2017-03-10 14:43:23 -0800 | [diff] [blame] | 218 | sed_hyphen_i -e "s/WITH_GCP_SUPPORT = True/WITH_GCP_SUPPORT = False/" tensorflow/core/platform/default/build_config.bzl |
A. Unique TensorFlower | 95a954a | 2016-12-28 13:40:08 -0800 | [diff] [blame] | 219 | fi |
| 220 | |
Jonathan Hseu | 9f5b098 | 2016-09-19 11:14:58 -0800 | [diff] [blame] | 221 | while [ "$TF_NEED_HDFS" == "" ]; do |
| 222 | read -p "Do you wish to build TensorFlow with "\ |
| 223 | "Hadoop File System support? [y/N] " INPUT |
| 224 | case $INPUT in |
| 225 | [Yy]* ) echo "Hadoop File System support will be enabled for "\ |
| 226 | "TensorFlow"; TF_NEED_HDFS=1;; |
| 227 | [Nn]* ) echo "No Hadoop File System support will be enabled for "\ |
| 228 | "TensorFlow"; TF_NEED_HDFS=0;; |
| 229 | "" ) echo "No Hadoop File System support will be enabled for "\ |
| 230 | "TensorFlow"; TF_NEED_HDFS=0;; |
| 231 | * ) echo "Invalid selection: " $INPUT;; |
| 232 | esac |
| 233 | done |
| 234 | |
| 235 | if [ "$TF_NEED_HDFS" == "1" ]; then |
| 236 | # Update Bazel build configuration. |
Dandelion Mané | 0386a01 | 2017-03-10 14:43:23 -0800 | [diff] [blame] | 237 | sed_hyphen_i -e "s/WITH_HDFS_SUPPORT = False/WITH_HDFS_SUPPORT = True/" tensorflow/core/platform/default/build_config.bzl |
Jonathan Hseu | 9f5b098 | 2016-09-19 11:14:58 -0800 | [diff] [blame] | 238 | else |
| 239 | # Update Bazel build configuration. |
Dandelion Mané | 0386a01 | 2017-03-10 14:43:23 -0800 | [diff] [blame] | 240 | sed_hyphen_i -e "s/WITH_HDFS_SUPPORT = True/WITH_HDFS_SUPPORT = False/" tensorflow/core/platform/default/build_config.bzl |
Jonathan Hseu | 9f5b098 | 2016-09-19 11:14:58 -0800 | [diff] [blame] | 241 | fi |
| 242 | |
Peter Hawkins | 1e67c90 | 2017-01-09 12:04:37 -0800 | [diff] [blame] | 243 | ## Enable XLA. |
| 244 | while [ "$TF_ENABLE_XLA" == "" ]; do |
| 245 | read -p "Do you wish to build TensorFlow with the XLA just-in-time compiler (experimental)? [y/N] " INPUT |
| 246 | case $INPUT in |
| 247 | [Yy]* ) echo "XLA JIT support will be enabled for TensorFlow"; TF_ENABLE_XLA=1;; |
| 248 | [Nn]* ) echo "No XLA JIT support will be enabled for TensorFlow"; TF_ENABLE_XLA=0;; |
| 249 | "" ) echo "No XLA support will be enabled for TensorFlow"; TF_ENABLE_XLA=0;; |
| 250 | * ) echo "Invalid selection: " $INPUT;; |
| 251 | esac |
| 252 | done |
| 253 | |
| 254 | if [ "$TF_ENABLE_XLA" == "1" ]; then |
| 255 | # Update Bazel build configuration. |
Dandelion Mané | 0386a01 | 2017-03-10 14:43:23 -0800 | [diff] [blame] | 256 | sed_hyphen_i -e "s/^WITH_XLA_SUPPORT = [FT].*/WITH_XLA_SUPPORT = True/" tensorflow/core/platform/default/build_config_root.bzl |
Peter Hawkins | 1e67c90 | 2017-01-09 12:04:37 -0800 | [diff] [blame] | 257 | else |
| 258 | # Update Bazel build configuration. |
Dandelion Mané | 0386a01 | 2017-03-10 14:43:23 -0800 | [diff] [blame] | 259 | sed_hyphen_i -e "s/^WITH_XLA_SUPPORT = [FT].*/WITH_XLA_SUPPORT = False/" tensorflow/core/platform/default/build_config_root.bzl |
Peter Hawkins | 1e67c90 | 2017-01-09 12:04:37 -0800 | [diff] [blame] | 260 | fi |
| 261 | |
| 262 | |
Vijay Vasudevan | bf6b536 | 2015-12-02 15:04:40 -0800 | [diff] [blame] | 263 | # Invoke python_config and set up symlinks to python includes |
A. Unique TensorFlower | edaf3b3 | 2016-10-10 10:26:22 -0800 | [diff] [blame] | 264 | ./util/python/python_config.sh --setup "$PYTHON_BIN_PATH" |
Vijay Vasudevan | bf6b536 | 2015-12-02 15:04:40 -0800 | [diff] [blame] | 265 | |
Martin Wicke | c4e3d4a | 2017-01-13 12:20:42 -0800 | [diff] [blame] | 266 | # Append CC optimization flags to bazel.rc |
| 267 | echo >> tools/bazel.rc |
| 268 | for opt in $CC_OPT_FLAGS; do |
Gunhan Gulsoy | acdbd68 | 2017-01-16 01:21:51 -0800 | [diff] [blame] | 269 | echo "build:opt --cxxopt=$opt --copt=$opt" >> tools/bazel.rc |
Martin Wicke | c4e3d4a | 2017-01-13 12:20:42 -0800 | [diff] [blame] | 270 | done |
| 271 | |
Andrew Selle | 09045e4 | 2016-09-06 08:19:04 -0800 | [diff] [blame] | 272 | # Run the gen_git_source to create links where bazel can track dependencies for |
| 273 | # git hash propagation |
| 274 | GEN_GIT_SOURCE=tensorflow/tools/git/gen_git_source.py |
| 275 | chmod a+x ${GEN_GIT_SOURCE} |
Patrick Nguyen | c5ab3dd | 2016-10-20 12:09:18 -0800 | [diff] [blame] | 276 | "${PYTHON_BIN_PATH}" ${GEN_GIT_SOURCE} --configure "${SOURCE_BASE_DIR}" |
Andrew Selle | 09045e4 | 2016-09-06 08:19:04 -0800 | [diff] [blame] | 277 | |
Benoit Steiner | a771598 | 2016-11-09 13:14:03 -0800 | [diff] [blame] | 278 | ## Set up SYCL-related environment settings |
| 279 | while [ "$TF_NEED_OPENCL" == "" ]; do |
| 280 | read -p "Do you wish to build TensorFlow with OpenCL support? [y/N] " INPUT |
| 281 | case $INPUT in |
| 282 | [Yy]* ) echo "OpenCL support will be enabled for TensorFlow"; TF_NEED_OPENCL=1;; |
| 283 | [Nn]* ) echo "No OpenCL support will be enabled for TensorFlow"; TF_NEED_OPENCL=0;; |
| 284 | "" ) echo "No OpenCL support will be enabled for TensorFlow"; TF_NEED_OPENCL=0;; |
| 285 | * ) echo "Invalid selection: " $INPUT;; |
| 286 | esac |
| 287 | done |
| 288 | |
Manjunath Kudlur | f41959c | 2015-11-06 16:27:58 -0800 | [diff] [blame] | 289 | ## Set up Cuda-related environment settings |
| 290 | |
| 291 | while [ "$TF_NEED_CUDA" == "" ]; do |
Andrew Harp | 1cb9689 | 2016-12-08 20:05:49 -0800 | [diff] [blame] | 292 | read -p "Do you wish to build TensorFlow with CUDA support? [y/N] " INPUT |
Manjunath Kudlur | f41959c | 2015-11-06 16:27:58 -0800 | [diff] [blame] | 293 | case $INPUT in |
Andrew Harp | 1cb9689 | 2016-12-08 20:05:49 -0800 | [diff] [blame] | 294 | [Yy]* ) echo "CUDA support will be enabled for TensorFlow"; TF_NEED_CUDA=1;; |
| 295 | [Nn]* ) echo "No CUDA support will be enabled for TensorFlow"; TF_NEED_CUDA=0;; |
| 296 | "" ) echo "No CUDA support will be enabled for TensorFlow"; TF_NEED_CUDA=0;; |
Manjunath Kudlur | f41959c | 2015-11-06 16:27:58 -0800 | [diff] [blame] | 297 | * ) echo "Invalid selection: " $INPUT;; |
| 298 | esac |
| 299 | done |
| 300 | |
A. Unique TensorFlower | 2c598e8 | 2016-08-25 10:22:44 -0800 | [diff] [blame] | 301 | export TF_NEED_CUDA |
Rohan Jain | aab0997 | 2017-01-05 14:39:17 -0800 | [diff] [blame] | 302 | export TF_NEED_OPENCL |
Benoit Steiner | a771598 | 2016-11-09 13:14:03 -0800 | [diff] [blame] | 303 | if [[ "$TF_NEED_CUDA" == "0" ]] && [[ "$TF_NEED_OPENCL" == "0" ]]; then |
Manjunath Kudlur | f41959c | 2015-11-06 16:27:58 -0800 | [diff] [blame] | 304 | echo "Configuration finished" |
Jonathan Hseu | 1283b84 | 2016-09-29 15:05:32 -0800 | [diff] [blame] | 305 | bazel_clean_and_fetch |
Manjunath Kudlur | f41959c | 2015-11-06 16:27:58 -0800 | [diff] [blame] | 306 | exit |
| 307 | fi |
| 308 | |
Benoit Steiner | a771598 | 2016-11-09 13:14:03 -0800 | [diff] [blame] | 309 | if [ "$TF_NEED_CUDA" == "1" ]; then |
Vijay Vasudevan | 80a5a3e | 2016-03-29 18:23:11 -0800 | [diff] [blame] | 310 | # Set up which gcc nvcc should use as the host compiler |
Andrew Harp | 1cb9689 | 2016-12-08 20:05:49 -0800 | [diff] [blame] | 311 | # No need to set this on Windows |
| 312 | while ! is_windows && true; do |
Vijay Vasudevan | 80a5a3e | 2016-03-29 18:23:11 -0800 | [diff] [blame] | 313 | fromuser="" |
| 314 | if [ -z "$GCC_HOST_COMPILER_PATH" ]; then |
A. Unique TensorFlower | edaf3b3 | 2016-10-10 10:26:22 -0800 | [diff] [blame] | 315 | default_gcc_host_compiler_path=$(which gcc || true) |
Shanqing Cai | a81c4f9 | 2016-07-22 10:37:35 -0800 | [diff] [blame] | 316 | read -p "Please specify which gcc should be used by nvcc as the host compiler. [Default is $default_gcc_host_compiler_path]: " GCC_HOST_COMPILER_PATH |
Vijay Vasudevan | 80a5a3e | 2016-03-29 18:23:11 -0800 | [diff] [blame] | 317 | fromuser="1" |
| 318 | if [ -z "$GCC_HOST_COMPILER_PATH" ]; then |
Andrew Harp | 1cb9689 | 2016-12-08 20:05:49 -0800 | [diff] [blame] | 319 | GCC_HOST_COMPILER_PATH="$default_gcc_host_compiler_path" |
Vijay Vasudevan | 80a5a3e | 2016-03-29 18:23:11 -0800 | [diff] [blame] | 320 | fi |
| 321 | fi |
| 322 | if [ -e "$GCC_HOST_COMPILER_PATH" ]; then |
A. Unique TensorFlower | b0bdff4 | 2016-08-26 12:50:48 -0800 | [diff] [blame] | 323 | export GCC_HOST_COMPILER_PATH |
Vijay Vasudevan | 80a5a3e | 2016-03-29 18:23:11 -0800 | [diff] [blame] | 324 | break |
| 325 | fi |
| 326 | echo "Invalid gcc path. ${GCC_HOST_COMPILER_PATH} cannot be found" 1>&2 |
| 327 | if [ -z "$fromuser" ]; then |
| 328 | exit 1 |
| 329 | fi |
| 330 | GCC_HOST_COMPILER_PATH="" |
| 331 | # Retry |
| 332 | done |
| 333 | |
Manjunath Kudlur | f41959c | 2015-11-06 16:27:58 -0800 | [diff] [blame] | 334 | # Find out where the CUDA toolkit is installed |
| 335 | while true; do |
A. Unique TensorFlower | 8a59748 | 2016-01-29 09:34:18 -0800 | [diff] [blame] | 336 | # Configure the Cuda SDK version to use. |
A. Unique TensorFlower | 8a59748 | 2016-01-29 09:34:18 -0800 | [diff] [blame] | 337 | if [ -z "$TF_CUDA_VERSION" ]; then |
Andrew Harp | 1cb9689 | 2016-12-08 20:05:49 -0800 | [diff] [blame] | 338 | read -p "Please specify the CUDA SDK version you want to use, e.g. 7.0. [Leave empty to use system default]: " TF_CUDA_VERSION |
A. Unique TensorFlower | 8a59748 | 2016-01-29 09:34:18 -0800 | [diff] [blame] | 339 | fi |
| 340 | |
Manjunath Kudlur | f41959c | 2015-11-06 16:27:58 -0800 | [diff] [blame] | 341 | fromuser="" |
| 342 | if [ -z "$CUDA_TOOLKIT_PATH" ]; then |
| 343 | default_cuda_path=/usr/local/cuda |
Andrew Harp | 1cb9689 | 2016-12-08 20:05:49 -0800 | [diff] [blame] | 344 | if is_windows; then |
| 345 | if [ -z "$CUDA_PATH" ]; then |
| 346 | default_cuda_path="C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v8.0" |
| 347 | else |
| 348 | default_cuda_path="$(cygpath -m "$CUDA_PATH")" |
| 349 | fi |
| 350 | fi |
A. Unique TensorFlower | 8a59748 | 2016-01-29 09:34:18 -0800 | [diff] [blame] | 351 | read -p "Please specify the location where CUDA $TF_CUDA_VERSION toolkit is installed. Refer to README.md for more details. [Default is $default_cuda_path]: " CUDA_TOOLKIT_PATH |
Manjunath Kudlur | f41959c | 2015-11-06 16:27:58 -0800 | [diff] [blame] | 352 | fromuser="1" |
| 353 | if [ -z "$CUDA_TOOLKIT_PATH" ]; then |
Andrew Harp | 1cb9689 | 2016-12-08 20:05:49 -0800 | [diff] [blame] | 354 | CUDA_TOOLKIT_PATH="$default_cuda_path" |
Manjunath Kudlur | f41959c | 2015-11-06 16:27:58 -0800 | [diff] [blame] | 355 | fi |
| 356 | fi |
A. Unique TensorFlower | 8bf6ef1 | 2016-05-05 08:36:05 -0800 | [diff] [blame] | 357 | |
Vijay Vasudevan | fe056f0 | 2016-02-17 11:42:30 -0800 | [diff] [blame] | 358 | if [[ -z "$TF_CUDA_VERSION" ]]; then |
| 359 | TF_CUDA_EXT="" |
| 360 | else |
| 361 | TF_CUDA_EXT=".$TF_CUDA_VERSION" |
| 362 | fi |
A. Unique TensorFlower | 8bf6ef1 | 2016-05-05 08:36:05 -0800 | [diff] [blame] | 363 | |
Andrew Harp | 1cb9689 | 2016-12-08 20:05:49 -0800 | [diff] [blame] | 364 | if is_windows; then |
| 365 | CUDA_RT_LIB_PATH="lib/x64/cudart.lib" |
Jonathan Hseu | c058a01 | 2017-01-17 15:06:43 -0800 | [diff] [blame] | 366 | elif is_linux; then |
A. Unique TensorFlower | 8bf6ef1 | 2016-05-05 08:36:05 -0800 | [diff] [blame] | 367 | CUDA_RT_LIB_PATH="lib64/libcudart.so${TF_CUDA_EXT}" |
Jonathan Hseu | c058a01 | 2017-01-17 15:06:43 -0800 | [diff] [blame] | 368 | elif is_macos; then |
A. Unique TensorFlower | 8bf6ef1 | 2016-05-05 08:36:05 -0800 | [diff] [blame] | 369 | CUDA_RT_LIB_PATH="lib/libcudart${TF_CUDA_EXT}.dylib" |
| 370 | fi |
| 371 | |
| 372 | if [ -e "${CUDA_TOOLKIT_PATH}/${CUDA_RT_LIB_PATH}" ]; then |
A. Unique TensorFlower | 2c598e8 | 2016-08-25 10:22:44 -0800 | [diff] [blame] | 373 | export CUDA_TOOLKIT_PATH |
A. Unique TensorFlower | b0bdff4 | 2016-08-26 12:50:48 -0800 | [diff] [blame] | 374 | export TF_CUDA_VERSION |
Manjunath Kudlur | f41959c | 2015-11-06 16:27:58 -0800 | [diff] [blame] | 375 | break |
| 376 | fi |
A. Unique TensorFlower | 8bf6ef1 | 2016-05-05 08:36:05 -0800 | [diff] [blame] | 377 | echo "Invalid path to CUDA $TF_CUDA_VERSION toolkit. ${CUDA_TOOLKIT_PATH}/${CUDA_RT_LIB_PATH} cannot be found" |
| 378 | |
Manjunath Kudlur | f41959c | 2015-11-06 16:27:58 -0800 | [diff] [blame] | 379 | if [ -z "$fromuser" ]; then |
| 380 | exit 1 |
| 381 | fi |
Vijay Vasudevan | fe056f0 | 2016-02-17 11:42:30 -0800 | [diff] [blame] | 382 | # Retry |
A. Unique TensorFlower | 8a59748 | 2016-01-29 09:34:18 -0800 | [diff] [blame] | 383 | TF_CUDA_VERSION="" |
Manjunath Kudlur | f41959c | 2015-11-06 16:27:58 -0800 | [diff] [blame] | 384 | CUDA_TOOLKIT_PATH="" |
Manjunath Kudlur | f41959c | 2015-11-06 16:27:58 -0800 | [diff] [blame] | 385 | done |
| 386 | |
Martin Wicke | 916776a | 2016-01-14 07:30:00 -0800 | [diff] [blame] | 387 | # Find out where the cuDNN library is installed |
Manjunath Kudlur | f41959c | 2015-11-06 16:27:58 -0800 | [diff] [blame] | 388 | while true; do |
A. Unique TensorFlower | 8a59748 | 2016-01-29 09:34:18 -0800 | [diff] [blame] | 389 | # Configure the Cudnn version to use. |
A. Unique TensorFlower | 8a59748 | 2016-01-29 09:34:18 -0800 | [diff] [blame] | 390 | if [ -z "$TF_CUDNN_VERSION" ]; then |
Vijay Vasudevan | fe056f0 | 2016-02-17 11:42:30 -0800 | [diff] [blame] | 391 | read -p "Please specify the Cudnn version you want to use. [Leave empty to use system default]: " TF_CUDNN_VERSION |
A. Unique TensorFlower | 8a59748 | 2016-01-29 09:34:18 -0800 | [diff] [blame] | 392 | fi |
| 393 | |
Manjunath Kudlur | f41959c | 2015-11-06 16:27:58 -0800 | [diff] [blame] | 394 | fromuser="" |
| 395 | if [ -z "$CUDNN_INSTALL_PATH" ]; then |
| 396 | default_cudnn_path=${CUDA_TOOLKIT_PATH} |
A. Unique TensorFlower | 8a59748 | 2016-01-29 09:34:18 -0800 | [diff] [blame] | 397 | read -p "Please specify the location where cuDNN $TF_CUDNN_VERSION library is installed. Refer to README.md for more details. [Default is $default_cudnn_path]: " CUDNN_INSTALL_PATH |
Manjunath Kudlur | f41959c | 2015-11-06 16:27:58 -0800 | [diff] [blame] | 398 | fromuser="1" |
| 399 | if [ -z "$CUDNN_INSTALL_PATH" ]; then |
| 400 | CUDNN_INSTALL_PATH=$default_cudnn_path |
| 401 | fi |
| 402 | # Result returned from "read" will be used unexpanded. That make "~" unuseable. |
| 403 | # Going through one more level of expansion to handle that. |
Andrew Harp | 1cb9689 | 2016-12-08 20:05:49 -0800 | [diff] [blame] | 404 | CUDNN_INSTALL_PATH=`"${PYTHON_BIN_PATH}" -c "import os; print(os.path.realpath(os.path.expanduser('${CUDNN_INSTALL_PATH}')))"` |
Manjunath Kudlur | f41959c | 2015-11-06 16:27:58 -0800 | [diff] [blame] | 405 | fi |
A. Unique TensorFlower | 8bf6ef1 | 2016-05-05 08:36:05 -0800 | [diff] [blame] | 406 | |
Vijay Vasudevan | fe056f0 | 2016-02-17 11:42:30 -0800 | [diff] [blame] | 407 | if [[ -z "$TF_CUDNN_VERSION" ]]; then |
| 408 | TF_CUDNN_EXT="" |
| 409 | else |
Benoit Steiner | 639b4e7 | 2017-02-08 09:25:09 -0800 | [diff] [blame] | 410 | TF_CUDNN_EXT=".$TF_CUDNN_VERSION" |
Vijay Vasudevan | fe056f0 | 2016-02-17 11:42:30 -0800 | [diff] [blame] | 411 | fi |
A. Unique TensorFlower | 8bf6ef1 | 2016-05-05 08:36:05 -0800 | [diff] [blame] | 412 | |
Andrew Harp | 1cb9689 | 2016-12-08 20:05:49 -0800 | [diff] [blame] | 413 | if is_windows; then |
| 414 | CUDA_DNN_LIB_PATH="lib/x64/cudnn.lib" |
| 415 | CUDA_DNN_LIB_ALT_PATH="lib/x64/cudnn.lib" |
Jonathan Hseu | c058a01 | 2017-01-17 15:06:43 -0800 | [diff] [blame] | 416 | elif is_linux; then |
A. Unique TensorFlower | 8bf6ef1 | 2016-05-05 08:36:05 -0800 | [diff] [blame] | 417 | CUDA_DNN_LIB_PATH="lib64/libcudnn.so${TF_CUDNN_EXT}" |
| 418 | CUDA_DNN_LIB_ALT_PATH="libcudnn.so${TF_CUDNN_EXT}" |
Jonathan Hseu | c058a01 | 2017-01-17 15:06:43 -0800 | [diff] [blame] | 419 | elif is_macos; then |
Benoit Steiner | 639b4e7 | 2017-02-08 09:25:09 -0800 | [diff] [blame] | 420 | CUDA_DNN_LIB_PATH="lib/libcudnn${TF_CUDNN_EXT}.dylib" |
| 421 | CUDA_DNN_LIB_ALT_PATH="libcudnn${TF_CUDNN_EXT}.dylib" |
A. Unique TensorFlower | 8bf6ef1 | 2016-05-05 08:36:05 -0800 | [diff] [blame] | 422 | fi |
| 423 | |
| 424 | if [ -e "$CUDNN_INSTALL_PATH/${CUDA_DNN_LIB_ALT_PATH}" -o -e "$CUDNN_INSTALL_PATH/${CUDA_DNN_LIB_PATH}" ]; then |
A. Unique TensorFlower | b0bdff4 | 2016-08-26 12:50:48 -0800 | [diff] [blame] | 425 | export TF_CUDNN_VERSION |
A. Unique TensorFlower | 2c598e8 | 2016-08-25 10:22:44 -0800 | [diff] [blame] | 426 | export CUDNN_INSTALL_PATH |
Eugene Brevdo | 56f1d64 | 2016-03-10 17:18:30 -0800 | [diff] [blame] | 427 | break |
| 428 | fi |
A. Unique TensorFlower | 8bf6ef1 | 2016-05-05 08:36:05 -0800 | [diff] [blame] | 429 | |
Jonathan Hseu | c058a01 | 2017-01-17 15:06:43 -0800 | [diff] [blame] | 430 | if is_linux; then |
Vijay Vasudevan | 93a975e | 2017-02-17 17:05:49 -0800 | [diff] [blame] | 431 | if ! type ldconfig > /dev/null 2>&1; then |
| 432 | LDCONFIG_BIN=/sbin/ldconfig |
| 433 | else |
| 434 | LDCONFIG_BIN=ldconfig |
| 435 | fi |
| 436 | CUDNN_PATH_FROM_LDCONFIG="$($LDCONFIG_BIN -p | sed -n 's/.*libcudnn.so .* => \(.*\)/\1/p')" |
A. Unique TensorFlower | 8bf6ef1 | 2016-05-05 08:36:05 -0800 | [diff] [blame] | 437 | if [ -e "${CUDNN_PATH_FROM_LDCONFIG}${TF_CUDNN_EXT}" ]; then |
A. Unique TensorFlower | b0bdff4 | 2016-08-26 12:50:48 -0800 | [diff] [blame] | 438 | export TF_CUDNN_VERSION |
A. Unique TensorFlower | 2c598e8 | 2016-08-25 10:22:44 -0800 | [diff] [blame] | 439 | export CUDNN_INSTALL_PATH="$(dirname ${CUDNN_PATH_FROM_LDCONFIG})" |
A. Unique TensorFlower | 8bf6ef1 | 2016-05-05 08:36:05 -0800 | [diff] [blame] | 440 | break |
| 441 | fi |
Manjunath Kudlur | f41959c | 2015-11-06 16:27:58 -0800 | [diff] [blame] | 442 | fi |
A. Unique TensorFlower | 8bf6ef1 | 2016-05-05 08:36:05 -0800 | [diff] [blame] | 443 | echo "Invalid path to cuDNN ${CUDNN_VERSION} toolkit. Neither of the following two files can be found:" |
| 444 | echo "${CUDNN_INSTALL_PATH}/${CUDA_DNN_LIB_PATH}" |
| 445 | echo "${CUDNN_INSTALL_PATH}/${CUDA_DNN_LIB_ALT_PATH}" |
Jonathan Hseu | c058a01 | 2017-01-17 15:06:43 -0800 | [diff] [blame] | 446 | if is_linux; then |
A. Unique TensorFlower | 8bf6ef1 | 2016-05-05 08:36:05 -0800 | [diff] [blame] | 447 | echo "${CUDNN_PATH_FROM_LDCONFIG}${TF_CUDNN_EXT}" |
| 448 | fi |
| 449 | |
Manjunath Kudlur | f41959c | 2015-11-06 16:27:58 -0800 | [diff] [blame] | 450 | if [ -z "$fromuser" ]; then |
| 451 | exit 1 |
| 452 | fi |
Vijay Vasudevan | fe056f0 | 2016-02-17 11:42:30 -0800 | [diff] [blame] | 453 | # Retry |
A. Unique TensorFlower | 8a59748 | 2016-01-29 09:34:18 -0800 | [diff] [blame] | 454 | TF_CUDNN_VERSION="" |
Manjunath Kudlur | f41959c | 2015-11-06 16:27:58 -0800 | [diff] [blame] | 455 | CUDNN_INSTALL_PATH="" |
Manjunath Kudlur | f41959c | 2015-11-06 16:27:58 -0800 | [diff] [blame] | 456 | done |
| 457 | |
Vijay Vasudevan | fe056f0 | 2016-02-17 11:42:30 -0800 | [diff] [blame] | 458 | # Configure the compute capabilities that TensorFlow builds for. |
| 459 | # Since Cuda toolkit is not backward-compatible, this is not guaranteed to work. |
| 460 | while true; do |
| 461 | fromuser="" |
A. Unique TensorFlower | 2c598e8 | 2016-08-25 10:22:44 -0800 | [diff] [blame] | 462 | default_cuda_compute_capabilities="3.5,5.2" |
Vijay Vasudevan | fe056f0 | 2016-02-17 11:42:30 -0800 | [diff] [blame] | 463 | if [ -z "$TF_CUDA_COMPUTE_CAPABILITIES" ]; then |
Vijay Vasudevan | 4dffee7 | 2015-11-12 11:27:00 -0800 | [diff] [blame] | 464 | cat << EOF |
| 465 | Please specify a list of comma-separated Cuda compute capabilities you want to build with. |
| 466 | You can find the compute capability of your device at: https://developer.nvidia.com/cuda-gpus. |
| 467 | Please note that each additional compute capability significantly increases your build time and binary size. |
| 468 | EOF |
Vijay Vasudevan | fe056f0 | 2016-02-17 11:42:30 -0800 | [diff] [blame] | 469 | read -p "[Default is: \"3.5,5.2\"]: " TF_CUDA_COMPUTE_CAPABILITIES |
| 470 | fromuser=1 |
| 471 | fi |
A. Unique TensorFlower | 2c598e8 | 2016-08-25 10:22:44 -0800 | [diff] [blame] | 472 | if [ -z "$TF_CUDA_COMPUTE_CAPABILITIES" ]; then |
| 473 | TF_CUDA_COMPUTE_CAPABILITIES=$default_cuda_compute_capabilities |
| 474 | fi |
Vijay Vasudevan | fe056f0 | 2016-02-17 11:42:30 -0800 | [diff] [blame] | 475 | # Check whether all capabilities from the input is valid |
| 476 | COMPUTE_CAPABILITIES=${TF_CUDA_COMPUTE_CAPABILITIES//,/ } |
| 477 | ALL_VALID=1 |
| 478 | for CAPABILITY in $COMPUTE_CAPABILITIES; do |
| 479 | if [[ ! "$CAPABILITY" =~ [0-9]+.[0-9]+ ]]; then |
| 480 | echo "Invalid compute capability: " $CAPABILITY |
| 481 | ALL_VALID=0 |
Vijay Vasudevan | 4dffee7 | 2015-11-12 11:27:00 -0800 | [diff] [blame] | 482 | break |
| 483 | fi |
Vijay Vasudevan | 4dffee7 | 2015-11-12 11:27:00 -0800 | [diff] [blame] | 484 | done |
Vijay Vasudevan | fe056f0 | 2016-02-17 11:42:30 -0800 | [diff] [blame] | 485 | if [ "$ALL_VALID" == "0" ]; then |
| 486 | if [ -z "$fromuser" ]; then |
| 487 | exit 1 |
| 488 | fi |
| 489 | else |
A. Unique TensorFlower | b0bdff4 | 2016-08-26 12:50:48 -0800 | [diff] [blame] | 490 | export TF_CUDA_COMPUTE_CAPABILITIES |
Vijay Vasudevan | fe056f0 | 2016-02-17 11:42:30 -0800 | [diff] [blame] | 491 | break |
Vijay Vasudevan | 4dffee7 | 2015-11-12 11:27:00 -0800 | [diff] [blame] | 492 | fi |
Vijay Vasudevan | fe056f0 | 2016-02-17 11:42:30 -0800 | [diff] [blame] | 493 | TF_CUDA_COMPUTE_CAPABILITIES="" |
| 494 | done |
Vijay Vasudevan | 4dffee7 | 2015-11-12 11:27:00 -0800 | [diff] [blame] | 495 | |
Andrew Harp | 1cb9689 | 2016-12-08 20:05:49 -0800 | [diff] [blame] | 496 | if is_windows; then |
| 497 | # The following three variables are needed for MSVC toolchain configuration in Bazel |
| 498 | export CUDA_PATH="$CUDA_TOOLKIT_PATH" |
| 499 | export CUDA_COMPUTE_CAPABILITIES="$TF_CUDA_COMPUTE_CAPABILITIES" |
| 500 | export NO_WHOLE_ARCHIVE_OPTION=1 |
| 501 | |
| 502 | # Set GCC_HOST_COMPILER_PATH to keep cuda_configure.bzl happy |
| 503 | export GCC_HOST_COMPILER_PATH="/usr/bin/dummy_compiler" |
| 504 | fi |
| 505 | |
Benoit Steiner | a771598 | 2016-11-09 13:14:03 -0800 | [diff] [blame] | 506 | # end of if "$TF_NEED_CUDA" == "1" |
| 507 | fi |
| 508 | |
| 509 | # OpenCL configuration |
| 510 | |
| 511 | if [ "$TF_NEED_OPENCL" == "1" ]; then |
| 512 | |
| 513 | # Determine which C++ compiler should be used as the host compiler |
| 514 | while true; do |
| 515 | fromuser="" |
| 516 | if [ -z "$HOST_CXX_COMPILER" ]; then |
Jonathan Hseu | bed8383 | 2016-12-22 15:38:30 -0800 | [diff] [blame] | 517 | default_cxx_host_compiler=$(which clang++-3.6 || true) |
Benoit Steiner | a771598 | 2016-11-09 13:14:03 -0800 | [diff] [blame] | 518 | read -p "Please specify which C++ compiler should be used as the host C++ compiler. [Default is $default_cxx_host_compiler]: " HOST_CXX_COMPILER |
| 519 | fromuser="1" |
| 520 | if [ -z "$HOST_CXX_COMPILER" ]; then |
| 521 | HOST_CXX_COMPILER=$default_cxx_host_compiler |
| 522 | fi |
| 523 | fi |
| 524 | if [ -e "$HOST_CXX_COMPILER" ]; then |
| 525 | export HOST_CXX_COMPILER |
| 526 | break |
| 527 | fi |
| 528 | echo "Invalid C++ compiler path. ${HOST_CXX_COMPILER} cannot be found" 1>&2 |
| 529 | if [ -z "$fromuser" ]; then |
| 530 | exit 1 |
| 531 | fi |
| 532 | HOST_CXX_COMPILER="" |
| 533 | # Retry |
| 534 | done |
| 535 | |
| 536 | # Determine which C compiler should be used as the host compiler |
| 537 | while true; do |
| 538 | fromuser="" |
| 539 | if [ -z "$HOST_C_COMPILER" ]; then |
Jonathan Hseu | bed8383 | 2016-12-22 15:38:30 -0800 | [diff] [blame] | 540 | default_c_host_compiler=$(which clang-3.6 || true) |
Benoit Steiner | a771598 | 2016-11-09 13:14:03 -0800 | [diff] [blame] | 541 | read -p "Please specify which C compiler should be used as the host C compiler. [Default is $default_c_host_compiler]: " HOST_C_COMPILER |
| 542 | fromuser="1" |
| 543 | if [ -z "$HOST_C_COMPILER" ]; then |
| 544 | HOST_C_COMPILER=$default_c_host_compiler |
| 545 | fi |
| 546 | fi |
| 547 | if [ -e "$HOST_C_COMPILER" ]; then |
| 548 | export HOST_C_COMPILER |
| 549 | break |
| 550 | fi |
| 551 | echo "Invalid C compiler path. ${HOST_C_COMPILER} cannot be found" 1>&2 |
| 552 | if [ -z "$fromuser" ]; then |
| 553 | exit 1 |
| 554 | fi |
| 555 | HOST_C_COMPILER="" |
| 556 | # Retry |
| 557 | done |
| 558 | |
| 559 | while true; do |
| 560 | # Configure the OPENCL version to use. |
| 561 | TF_OPENCL_VERSION="1.2" |
| 562 | |
| 563 | # Point to ComputeCpp root |
| 564 | if [ -z "$COMPUTECPP_TOOLKIT_PATH" ]; then |
| 565 | default_computecpp_toolkit_path=/usr/local/computecpp |
Martin Wicke | 2e4869a | 2016-12-14 15:46:53 -0800 | [diff] [blame] | 566 | read -p "Please specify the location where ComputeCpp for SYCL $TF_OPENCL_VERSION is installed. [Default is $default_computecpp_toolkit_path]: " COMPUTECPP_TOOLKIT_PATH |
Benoit Steiner | a771598 | 2016-11-09 13:14:03 -0800 | [diff] [blame] | 567 | fromuser="1" |
| 568 | if [ -z "$COMPUTECPP_TOOLKIT_PATH" ]; then |
| 569 | COMPUTECPP_TOOLKIT_PATH=$default_computecpp_toolkit_path |
| 570 | fi |
| 571 | fi |
| 572 | |
Jonathan Hseu | c058a01 | 2017-01-17 15:06:43 -0800 | [diff] [blame] | 573 | if is_linux; then |
Benoit Steiner | a771598 | 2016-11-09 13:14:03 -0800 | [diff] [blame] | 574 | SYCL_RT_LIB_PATH="lib/libComputeCpp.so" |
| 575 | fi |
| 576 | |
| 577 | if [ -e "${COMPUTECPP_TOOLKIT_PATH}/${SYCL_RT_LIB_PATH}" ]; then |
| 578 | export COMPUTECPP_TOOLKIT_PATH |
| 579 | break |
| 580 | fi |
| 581 | echo "Invalid SYCL $TF_OPENCL_VERSION library path. ${COMPUTECPP_TOOLKIT_PATH}/${SYCL_RT_LIB_PATH} cannot be found" |
| 582 | |
| 583 | if [ -z "$fromuser" ]; then |
| 584 | exit 1 |
| 585 | fi |
| 586 | # Retry |
| 587 | TF_OPENCL_VERSION="" |
| 588 | COMPUTECPP_TOOLKIT_PATH="" |
| 589 | done |
| 590 | |
Benoit Steiner | a771598 | 2016-11-09 13:14:03 -0800 | [diff] [blame] | 591 | # end of if "$TF_NEED_OPENCL" == "1" |
| 592 | fi |
| 593 | |
Jonathan Hseu | 1283b84 | 2016-09-29 15:05:32 -0800 | [diff] [blame] | 594 | bazel_clean_and_fetch |
Manjunath Kudlur | f41959c | 2015-11-06 16:27:58 -0800 | [diff] [blame] | 595 | |
| 596 | echo "Configuration finished" |