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