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 | |
Vijay Vasudevan | 80a5a3e | 2016-03-29 18:23:11 -0800 | [diff] [blame] | 3 | DO_NOT_SUBMIT_WARNING="Unofficial setting. DO NOT SUBMIT!!!" |
| 4 | |
Shanqing Cai | de6d48c | 2016-04-28 10:34:56 -0800 | [diff] [blame] | 5 | ## Verify that the submodule google/protobuf is available |
| 6 | # TODO(cais): Remove this check once protobuf is no longer depended upon |
| 7 | if [[ ! -f "google/protobuf/protobuf.bzl" ]]; then |
| 8 | echo "ERROR: It appears that the required submodule google/protobuf is not "\ |
| 9 | "available in this TensorFlow git clone." |
| 10 | echo "Please be sure to use the --recurse-submodules flag when performing "\ |
| 11 | "git clone of TensorFlow." |
| 12 | |
| 13 | exit 1 |
| 14 | fi |
| 15 | |
Vijay Vasudevan | bf6b536 | 2015-12-02 15:04:40 -0800 | [diff] [blame] | 16 | ## Set up python-related environment settings |
| 17 | while true; do |
| 18 | fromuser="" |
| 19 | if [ -z "$PYTHON_BIN_PATH" ]; then |
| 20 | default_python_bin_path=$(which python) |
| 21 | read -p "Please specify the location of python. [Default is $default_python_bin_path]: " PYTHON_BIN_PATH |
| 22 | fromuser="1" |
| 23 | if [ -z "$PYTHON_BIN_PATH" ]; then |
| 24 | PYTHON_BIN_PATH=$default_python_bin_path |
| 25 | fi |
| 26 | fi |
| 27 | if [ -e "$PYTHON_BIN_PATH" ]; then |
| 28 | break |
| 29 | fi |
| 30 | echo "Invalid python path. ${PYTHON_BIN_PATH} cannot be found" 1>&2 |
| 31 | if [ -z "$fromuser" ]; then |
| 32 | exit 1 |
| 33 | fi |
| 34 | PYTHON_BIN_PATH="" |
| 35 | # Retry |
| 36 | done |
| 37 | |
A. Unique TensorFlower | ed65e69 | 2016-05-11 21:03:48 -0800 | [diff] [blame^] | 38 | while [ "$TF_NEED_GCP" == "" ]; do |
| 39 | read -p "Do you wish to build TensorFlow with "\ |
| 40 | "Google Cloud Platform support? [y/N] " INPUT |
| 41 | case $INPUT in |
| 42 | [Yy]* ) echo "Google Cloud Platform support will be enabled for "\ |
| 43 | "TensorFlow"; TF_NEED_GCP=1;; |
| 44 | [Nn]* ) echo "No Google Cloud Platform support will be enabled for "\ |
| 45 | "TensorFlow"; TF_NEED_GCP=0;; |
| 46 | "" ) echo "No Google Cloud Platform support will be enabled for "\ |
| 47 | "TensorFlow"; TF_NEED_GCP=0;; |
| 48 | * ) echo "Invalid selection: " $INPUT;; |
| 49 | esac |
| 50 | done |
| 51 | |
| 52 | if [ "$TF_NEED_GCP" == "1" ]; then |
| 53 | |
| 54 | ## Verify that libcurl header files are available. |
| 55 | # Only check Linux, since on MacOS the header files are installed with XCode. |
| 56 | if [[ $(uname -a) =~ Linux ]] && [[ ! -f "/usr/include/curl/curl.h" ]]; then |
| 57 | echo "ERROR: It appears that the development version of libcurl is not "\ |
| 58 | "available. Please install the libcurl3-dev package." |
| 59 | exit 1 |
| 60 | fi |
| 61 | |
| 62 | # Update Bazel build configuration. |
| 63 | perl -pi -e "s,WITH_GCP_SUPPORT = (False|True),WITH_GCP_SUPPORT = True,s" tensorflow/core/platform/default/build_config.bzl |
| 64 | else |
| 65 | # Update Bazel build configuration. |
| 66 | perl -pi -e "s,WITH_GCP_SUPPORT = (False|True),WITH_GCP_SUPPORT = False,s" tensorflow/core/platform/default/build_config.bzl |
| 67 | fi |
| 68 | |
Vijay Vasudevan | 80a5a3e | 2016-03-29 18:23:11 -0800 | [diff] [blame] | 69 | ## Find swig path |
| 70 | if [ -z "$SWIG_PATH" ]; then |
| 71 | SWIG_PATH=`type -p swig 2> /dev/null` |
| 72 | fi |
| 73 | if [[ ! -e "$SWIG_PATH" ]]; then |
| 74 | echo "Can't find swig. Ensure swig is in \$PATH or set \$SWIG_PATH." |
| 75 | exit 1 |
| 76 | fi |
| 77 | echo "$SWIG_PATH" > tensorflow/tools/swig/swig_path |
| 78 | |
Vijay Vasudevan | bf6b536 | 2015-12-02 15:04:40 -0800 | [diff] [blame] | 79 | # Invoke python_config and set up symlinks to python includes |
| 80 | (./util/python/python_config.sh --setup "$PYTHON_BIN_PATH";) || exit -1 |
| 81 | |
Manjunath Kudlur | f41959c | 2015-11-06 16:27:58 -0800 | [diff] [blame] | 82 | ## Set up Cuda-related environment settings |
| 83 | |
| 84 | while [ "$TF_NEED_CUDA" == "" ]; do |
Vijay Vasudevan | bf6b536 | 2015-12-02 15:04:40 -0800 | [diff] [blame] | 85 | read -p "Do you wish to build TensorFlow with GPU support? [y/N] " INPUT |
Manjunath Kudlur | f41959c | 2015-11-06 16:27:58 -0800 | [diff] [blame] | 86 | case $INPUT in |
Vijay Vasudevan | bf6b536 | 2015-12-02 15:04:40 -0800 | [diff] [blame] | 87 | [Yy]* ) echo "GPU support will be enabled for TensorFlow"; TF_NEED_CUDA=1;; |
| 88 | [Nn]* ) echo "No GPU support will be enabled for TensorFlow"; TF_NEED_CUDA=0;; |
| 89 | "" ) echo "No GPU support will be enabled for TensorFlow"; TF_NEED_CUDA=0;; |
Manjunath Kudlur | f41959c | 2015-11-06 16:27:58 -0800 | [diff] [blame] | 90 | * ) echo "Invalid selection: " $INPUT;; |
| 91 | esac |
| 92 | done |
| 93 | |
| 94 | if [ "$TF_NEED_CUDA" == "0" ]; then |
| 95 | echo "Configuration finished" |
| 96 | exit |
| 97 | fi |
| 98 | |
Vijay Vasudevan | 80a5a3e | 2016-03-29 18:23:11 -0800 | [diff] [blame] | 99 | # Set up which gcc nvcc should use as the host compiler |
| 100 | while true; do |
| 101 | fromuser="" |
| 102 | if [ -z "$GCC_HOST_COMPILER_PATH" ]; then |
| 103 | default_gcc_host_compiler_path=$(which gcc) |
| 104 | read -p "Please specify which gcc nvcc should use as the host compiler. [Default is $default_gcc_host_compiler_path]: " GCC_HOST_COMPILER_PATH |
| 105 | fromuser="1" |
| 106 | if [ -z "$GCC_HOST_COMPILER_PATH" ]; then |
| 107 | GCC_HOST_COMPILER_PATH=$default_gcc_host_compiler_path |
| 108 | fi |
| 109 | fi |
| 110 | if [ -e "$GCC_HOST_COMPILER_PATH" ]; then |
| 111 | break |
| 112 | fi |
| 113 | echo "Invalid gcc path. ${GCC_HOST_COMPILER_PATH} cannot be found" 1>&2 |
| 114 | if [ -z "$fromuser" ]; then |
| 115 | exit 1 |
| 116 | fi |
| 117 | GCC_HOST_COMPILER_PATH="" |
| 118 | # Retry |
| 119 | done |
| 120 | |
| 121 | |
Manjunath Kudlur | f41959c | 2015-11-06 16:27:58 -0800 | [diff] [blame] | 122 | # Find out where the CUDA toolkit is installed |
A. Unique TensorFlower | 8bf6ef1 | 2016-05-05 08:36:05 -0800 | [diff] [blame] | 123 | OSNAME=`uname -s` |
| 124 | |
Manjunath Kudlur | f41959c | 2015-11-06 16:27:58 -0800 | [diff] [blame] | 125 | while true; do |
A. Unique TensorFlower | 8a59748 | 2016-01-29 09:34:18 -0800 | [diff] [blame] | 126 | # Configure the Cuda SDK version to use. |
A. Unique TensorFlower | 8a59748 | 2016-01-29 09:34:18 -0800 | [diff] [blame] | 127 | if [ -z "$TF_CUDA_VERSION" ]; then |
Vijay Vasudevan | fe056f0 | 2016-02-17 11:42:30 -0800 | [diff] [blame] | 128 | 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] | 129 | fi |
| 130 | |
Manjunath Kudlur | f41959c | 2015-11-06 16:27:58 -0800 | [diff] [blame] | 131 | fromuser="" |
| 132 | if [ -z "$CUDA_TOOLKIT_PATH" ]; then |
| 133 | default_cuda_path=/usr/local/cuda |
A. Unique TensorFlower | 8a59748 | 2016-01-29 09:34:18 -0800 | [diff] [blame] | 134 | 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] | 135 | fromuser="1" |
| 136 | if [ -z "$CUDA_TOOLKIT_PATH" ]; then |
| 137 | CUDA_TOOLKIT_PATH=$default_cuda_path |
| 138 | fi |
| 139 | fi |
A. Unique TensorFlower | 8bf6ef1 | 2016-05-05 08:36:05 -0800 | [diff] [blame] | 140 | |
Vijay Vasudevan | fe056f0 | 2016-02-17 11:42:30 -0800 | [diff] [blame] | 141 | if [[ -z "$TF_CUDA_VERSION" ]]; then |
| 142 | TF_CUDA_EXT="" |
| 143 | else |
| 144 | TF_CUDA_EXT=".$TF_CUDA_VERSION" |
| 145 | fi |
A. Unique TensorFlower | 8bf6ef1 | 2016-05-05 08:36:05 -0800 | [diff] [blame] | 146 | |
| 147 | if [ "$OSNAME" == "Linux" ]; then |
| 148 | CUDA_RT_LIB_PATH="lib64/libcudart.so${TF_CUDA_EXT}" |
| 149 | elif [ "$OSNAME" == "Darwin" ]; then |
| 150 | CUDA_RT_LIB_PATH="lib/libcudart${TF_CUDA_EXT}.dylib" |
| 151 | fi |
| 152 | |
| 153 | if [ -e "${CUDA_TOOLKIT_PATH}/${CUDA_RT_LIB_PATH}" ]; then |
Manjunath Kudlur | f41959c | 2015-11-06 16:27:58 -0800 | [diff] [blame] | 154 | break |
| 155 | fi |
A. Unique TensorFlower | 8bf6ef1 | 2016-05-05 08:36:05 -0800 | [diff] [blame] | 156 | echo "Invalid path to CUDA $TF_CUDA_VERSION toolkit. ${CUDA_TOOLKIT_PATH}/${CUDA_RT_LIB_PATH} cannot be found" |
| 157 | |
Manjunath Kudlur | f41959c | 2015-11-06 16:27:58 -0800 | [diff] [blame] | 158 | if [ -z "$fromuser" ]; then |
| 159 | exit 1 |
| 160 | fi |
Vijay Vasudevan | fe056f0 | 2016-02-17 11:42:30 -0800 | [diff] [blame] | 161 | # Retry |
A. Unique TensorFlower | 8a59748 | 2016-01-29 09:34:18 -0800 | [diff] [blame] | 162 | TF_CUDA_VERSION="" |
Manjunath Kudlur | f41959c | 2015-11-06 16:27:58 -0800 | [diff] [blame] | 163 | CUDA_TOOLKIT_PATH="" |
Manjunath Kudlur | f41959c | 2015-11-06 16:27:58 -0800 | [diff] [blame] | 164 | done |
| 165 | |
Martin Wicke | 916776a | 2016-01-14 07:30:00 -0800 | [diff] [blame] | 166 | # Find out where the cuDNN library is installed |
Manjunath Kudlur | f41959c | 2015-11-06 16:27:58 -0800 | [diff] [blame] | 167 | while true; do |
A. Unique TensorFlower | 8a59748 | 2016-01-29 09:34:18 -0800 | [diff] [blame] | 168 | # Configure the Cudnn version to use. |
A. Unique TensorFlower | 8a59748 | 2016-01-29 09:34:18 -0800 | [diff] [blame] | 169 | if [ -z "$TF_CUDNN_VERSION" ]; then |
Vijay Vasudevan | fe056f0 | 2016-02-17 11:42:30 -0800 | [diff] [blame] | 170 | 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] | 171 | fi |
| 172 | |
Manjunath Kudlur | f41959c | 2015-11-06 16:27:58 -0800 | [diff] [blame] | 173 | fromuser="" |
| 174 | if [ -z "$CUDNN_INSTALL_PATH" ]; then |
| 175 | default_cudnn_path=${CUDA_TOOLKIT_PATH} |
A. Unique TensorFlower | 8a59748 | 2016-01-29 09:34:18 -0800 | [diff] [blame] | 176 | 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] | 177 | fromuser="1" |
| 178 | if [ -z "$CUDNN_INSTALL_PATH" ]; then |
| 179 | CUDNN_INSTALL_PATH=$default_cudnn_path |
| 180 | fi |
| 181 | # Result returned from "read" will be used unexpanded. That make "~" unuseable. |
| 182 | # Going through one more level of expansion to handle that. |
A. Unique TensorFlower | 8bf6ef1 | 2016-05-05 08:36:05 -0800 | [diff] [blame] | 183 | 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] | 184 | fi |
A. Unique TensorFlower | 8bf6ef1 | 2016-05-05 08:36:05 -0800 | [diff] [blame] | 185 | |
Vijay Vasudevan | fe056f0 | 2016-02-17 11:42:30 -0800 | [diff] [blame] | 186 | if [[ -z "$TF_CUDNN_VERSION" ]]; then |
| 187 | TF_CUDNN_EXT="" |
| 188 | else |
| 189 | TF_CUDNN_EXT=".$TF_CUDNN_VERSION" |
| 190 | fi |
A. Unique TensorFlower | 8bf6ef1 | 2016-05-05 08:36:05 -0800 | [diff] [blame] | 191 | |
| 192 | if [ "$OSNAME" == "Linux" ]; then |
| 193 | CUDA_DNN_LIB_PATH="lib64/libcudnn.so${TF_CUDNN_EXT}" |
| 194 | CUDA_DNN_LIB_ALT_PATH="libcudnn.so${TF_CUDNN_EXT}" |
| 195 | elif [ "$OSNAME" == "Darwin" ]; then |
| 196 | CUDA_DNN_LIB_PATH="lib/libcudnn${TF_CUDNN_EXT}.dylib" |
| 197 | CUDA_DNN_LIB_ALT_PATH="libcudnn${TF_CUDNN_EXT}.dylib" |
| 198 | fi |
| 199 | |
| 200 | if [ -e "$CUDNN_INSTALL_PATH/${CUDA_DNN_LIB_ALT_PATH}" -o -e "$CUDNN_INSTALL_PATH/${CUDA_DNN_LIB_PATH}" ]; then |
Eugene Brevdo | 56f1d64 | 2016-03-10 17:18:30 -0800 | [diff] [blame] | 201 | break |
| 202 | fi |
A. Unique TensorFlower | 8bf6ef1 | 2016-05-05 08:36:05 -0800 | [diff] [blame] | 203 | |
| 204 | if [ "$OSNAME" == "Linux" ]; then |
| 205 | CUDNN_PATH_FROM_LDCONFIG="$(ldconfig -p | sed -n 's/.*libcudnn.so .* => \(.*\)/\1/p')" |
| 206 | if [ -e "${CUDNN_PATH_FROM_LDCONFIG}${TF_CUDNN_EXT}" ]; then |
| 207 | CUDNN_INSTALL_PATH="$(dirname ${CUDNN_PATH_FROM_LDCONFIG})" |
| 208 | break |
| 209 | fi |
Manjunath Kudlur | f41959c | 2015-11-06 16:27:58 -0800 | [diff] [blame] | 210 | fi |
A. Unique TensorFlower | 8bf6ef1 | 2016-05-05 08:36:05 -0800 | [diff] [blame] | 211 | echo "Invalid path to cuDNN ${CUDNN_VERSION} toolkit. Neither of the following two files can be found:" |
| 212 | echo "${CUDNN_INSTALL_PATH}/${CUDA_DNN_LIB_PATH}" |
| 213 | echo "${CUDNN_INSTALL_PATH}/${CUDA_DNN_LIB_ALT_PATH}" |
| 214 | if [ "$OSNAME" == "Linux" ]; then |
| 215 | echo "${CUDNN_PATH_FROM_LDCONFIG}${TF_CUDNN_EXT}" |
| 216 | fi |
| 217 | |
Manjunath Kudlur | f41959c | 2015-11-06 16:27:58 -0800 | [diff] [blame] | 218 | if [ -z "$fromuser" ]; then |
| 219 | exit 1 |
| 220 | fi |
Vijay Vasudevan | fe056f0 | 2016-02-17 11:42:30 -0800 | [diff] [blame] | 221 | # Retry |
A. Unique TensorFlower | 8a59748 | 2016-01-29 09:34:18 -0800 | [diff] [blame] | 222 | TF_CUDNN_VERSION="" |
Manjunath Kudlur | f41959c | 2015-11-06 16:27:58 -0800 | [diff] [blame] | 223 | CUDNN_INSTALL_PATH="" |
Manjunath Kudlur | f41959c | 2015-11-06 16:27:58 -0800 | [diff] [blame] | 224 | done |
| 225 | |
| 226 | cat > third_party/gpus/cuda/cuda.config <<EOF |
Vijay Vasudevan | fe056f0 | 2016-02-17 11:42:30 -0800 | [diff] [blame] | 227 | # CUDA_TOOLKIT_PATH refers to the CUDA toolkit. |
Manjunath Kudlur | f41959c | 2015-11-06 16:27:58 -0800 | [diff] [blame] | 228 | CUDA_TOOLKIT_PATH="$CUDA_TOOLKIT_PATH" |
Martin Wicke | 916776a | 2016-01-14 07:30:00 -0800 | [diff] [blame] | 229 | # CUDNN_INSTALL_PATH refers to the cuDNN toolkit. The cuDNN header and library |
Manjunath Kudlur | f41959c | 2015-11-06 16:27:58 -0800 | [diff] [blame] | 230 | # files can be either in this directory, or under include/ and lib64/ |
| 231 | # directories separately. |
| 232 | CUDNN_INSTALL_PATH="$CUDNN_INSTALL_PATH" |
A. Unique TensorFlower | 8a59748 | 2016-01-29 09:34:18 -0800 | [diff] [blame] | 233 | |
Vijay Vasudevan | fe056f0 | 2016-02-17 11:42:30 -0800 | [diff] [blame] | 234 | # The Cuda SDK version that should be used in this build (empty to use libcudart.so symlink) |
A. Unique TensorFlower | 8bf6ef1 | 2016-05-05 08:36:05 -0800 | [diff] [blame] | 235 | TF_CUDA_VERSION=$TF_CUDA_VERSION |
A. Unique TensorFlower | 8a59748 | 2016-01-29 09:34:18 -0800 | [diff] [blame] | 236 | |
A. Unique TensorFlower | 8bf6ef1 | 2016-05-05 08:36:05 -0800 | [diff] [blame] | 237 | # The Cudnn version that should be used in this build |
| 238 | TF_CUDNN_VERSION=$TF_CUDNN_VERSION |
Manjunath Kudlur | f41959c | 2015-11-06 16:27:58 -0800 | [diff] [blame] | 239 | EOF |
| 240 | |
Vijay Vasudevan | 80a5a3e | 2016-03-29 18:23:11 -0800 | [diff] [blame] | 241 | # Configure the gcc host compiler to use |
| 242 | export WARNING=$DO_NOT_SUBMIT_WARNING |
| 243 | perl -pi -e "s,CPU_COMPILER = \('.*'\),# \$ENV{WARNING}\nCPU_COMPILER = ('$GCC_HOST_COMPILER_PATH'),s" third_party/gpus/crosstool/clang/bin/crosstool_wrapper_driver_is_not_gcc |
| 244 | perl -pi -e "s,GCC_HOST_COMPILER_PATH = \('.*'\),# \$ENV{WARNING}\nGCC_HOST_COMPILER_PATH = ('$GCC_HOST_COMPILER_PATH'),s" third_party/gpus/crosstool/clang/bin/crosstool_wrapper_driver_is_not_gcc |
| 245 | |
A. Unique TensorFlower | 8bf6ef1 | 2016-05-05 08:36:05 -0800 | [diff] [blame] | 246 | # Configure the platform name. |
| 247 | perl -pi -e "s,PLATFORM = \".*\",PLATFORM = \"$OSNAME\",s" third_party/gpus/cuda/platform.bzl |
| 248 | |
Vijay Vasudevan | fe056f0 | 2016-02-17 11:42:30 -0800 | [diff] [blame] | 249 | # Configure the Cuda toolkit version to work with. |
A. Unique TensorFlower | 8bf6ef1 | 2016-05-05 08:36:05 -0800 | [diff] [blame] | 250 | perl -pi -e "s,(GetCudaVersion.*return )\"[0-9\.]*\",\1\"$TF_CUDA_VERSION\",s" tensorflow/stream_executor/dso_loader.cc |
| 251 | perl -pi -e "s,CUDA_VERSION = \"[0-9\.]*\",CUDA_VERSION = \"$TF_CUDA_VERSION\",s" third_party/gpus/cuda/platform.bzl |
A. Unique TensorFlower | 8a59748 | 2016-01-29 09:34:18 -0800 | [diff] [blame] | 252 | |
Vijay Vasudevan | fe056f0 | 2016-02-17 11:42:30 -0800 | [diff] [blame] | 253 | # Configure the Cudnn version to work with. |
A. Unique TensorFlower | 8bf6ef1 | 2016-05-05 08:36:05 -0800 | [diff] [blame] | 254 | perl -pi -e "s,(GetCudnnVersion.*return )\"[0-9\.]*\",\1\"$TF_CUDNN_VERSION\",s" tensorflow/stream_executor/dso_loader.cc |
| 255 | perl -pi -e "s,CUDNN_VERSION = \"[0-9\.]*\",CUDNN_VERSION = \"$TF_CUDNN_VERSION\",s" third_party/gpus/cuda/platform.bzl |
| 256 | |
Vijay Vasudevan | 4dffee7 | 2015-11-12 11:27:00 -0800 | [diff] [blame] | 257 | |
Vijay Vasudevan | fe056f0 | 2016-02-17 11:42:30 -0800 | [diff] [blame] | 258 | # Configure the compute capabilities that TensorFlow builds for. |
| 259 | # Since Cuda toolkit is not backward-compatible, this is not guaranteed to work. |
| 260 | while true; do |
| 261 | fromuser="" |
| 262 | if [ -z "$TF_CUDA_COMPUTE_CAPABILITIES" ]; then |
Vijay Vasudevan | 4dffee7 | 2015-11-12 11:27:00 -0800 | [diff] [blame] | 263 | cat << EOF |
| 264 | Please specify a list of comma-separated Cuda compute capabilities you want to build with. |
| 265 | You can find the compute capability of your device at: https://developer.nvidia.com/cuda-gpus. |
| 266 | Please note that each additional compute capability significantly increases your build time and binary size. |
| 267 | EOF |
Vijay Vasudevan | fe056f0 | 2016-02-17 11:42:30 -0800 | [diff] [blame] | 268 | read -p "[Default is: \"3.5,5.2\"]: " TF_CUDA_COMPUTE_CAPABILITIES |
| 269 | fromuser=1 |
| 270 | fi |
| 271 | # Check whether all capabilities from the input is valid |
| 272 | COMPUTE_CAPABILITIES=${TF_CUDA_COMPUTE_CAPABILITIES//,/ } |
| 273 | ALL_VALID=1 |
| 274 | for CAPABILITY in $COMPUTE_CAPABILITIES; do |
| 275 | if [[ ! "$CAPABILITY" =~ [0-9]+.[0-9]+ ]]; then |
| 276 | echo "Invalid compute capability: " $CAPABILITY |
| 277 | ALL_VALID=0 |
Vijay Vasudevan | 4dffee7 | 2015-11-12 11:27:00 -0800 | [diff] [blame] | 278 | break |
| 279 | fi |
Vijay Vasudevan | 4dffee7 | 2015-11-12 11:27:00 -0800 | [diff] [blame] | 280 | done |
Vijay Vasudevan | fe056f0 | 2016-02-17 11:42:30 -0800 | [diff] [blame] | 281 | if [ "$ALL_VALID" == "0" ]; then |
| 282 | if [ -z "$fromuser" ]; then |
| 283 | exit 1 |
| 284 | fi |
| 285 | else |
| 286 | break |
Vijay Vasudevan | 4dffee7 | 2015-11-12 11:27:00 -0800 | [diff] [blame] | 287 | fi |
Vijay Vasudevan | fe056f0 | 2016-02-17 11:42:30 -0800 | [diff] [blame] | 288 | TF_CUDA_COMPUTE_CAPABILITIES="" |
| 289 | done |
Vijay Vasudevan | 4dffee7 | 2015-11-12 11:27:00 -0800 | [diff] [blame] | 290 | |
Vijay Vasudevan | fe056f0 | 2016-02-17 11:42:30 -0800 | [diff] [blame] | 291 | if [ ! -z "$TF_CUDA_COMPUTE_CAPABILITIES" ]; then |
Vijay Vasudevan | 80a5a3e | 2016-03-29 18:23:11 -0800 | [diff] [blame] | 292 | export WARNING=$DO_NOT_SUBMIT_WARNING |
Vijay Vasudevan | fe056f0 | 2016-02-17 11:42:30 -0800 | [diff] [blame] | 293 | function CudaGenCodeOpts() { |
| 294 | OUTPUT="" |
| 295 | for CAPABILITY in $@; do |
| 296 | OUTPUT=${OUTPUT}" \"${CAPABILITY}\", " |
| 297 | done |
| 298 | echo $OUTPUT |
| 299 | } |
| 300 | export CUDA_GEN_CODES_OPTS=$(CudaGenCodeOpts ${TF_CUDA_COMPUTE_CAPABILITIES//,/ }) |
| 301 | perl -pi -0 -e 's,\n( *)([^\n]*supported_cuda_compute_capabilities\s*=\s*\[).*?(\]),\n\1# $ENV{WARNING}\n\1\2$ENV{CUDA_GEN_CODES_OPTS}\3,s' third_party/gpus/crosstool/clang/bin/crosstool_wrapper_driver_is_not_gcc |
| 302 | function CudaVersionOpts() { |
| 303 | OUTPUT="" |
| 304 | for CAPABILITY in $@; do |
| 305 | OUTPUT=$OUTPUT"CudaVersion(\"${CAPABILITY}\"), " |
| 306 | done |
| 307 | echo $OUTPUT |
| 308 | } |
| 309 | export CUDA_VERSION_OPTS=$(CudaVersionOpts ${TF_CUDA_COMPUTE_CAPABILITIES//,/ }) |
| 310 | perl -pi -0 -e 's,\n( *)([^\n]*supported_cuda_compute_capabilities\s*=\s*\{).*?(\}),\n\1// $ENV{WARNING}\n\1\2$ENV{CUDA_VERSION_OPTS}\3,s' tensorflow/core/common_runtime/gpu/gpu_device.cc |
Vijay Vasudevan | 4dffee7 | 2015-11-12 11:27:00 -0800 | [diff] [blame] | 311 | fi |
| 312 | |
Manjunath Kudlur | f41959c | 2015-11-06 16:27:58 -0800 | [diff] [blame] | 313 | # Invoke the cuda_config.sh and set up the TensorFlow's canonical view of the Cuda libraries |
| 314 | (cd third_party/gpus/cuda; ./cuda_config.sh;) || exit -1 |
| 315 | |
| 316 | echo "Configuration finished" |