blob: dce59586ab59100b90ef1410b499fe33eb6ddd80 [file] [log] [blame]
Geoffrey Irving4c85a082016-03-16 12:20:34 -08001#!/usr/bin/env bash
Manjunath Kudlurf41959c2015-11-06 16:27:58 -08002
A. Unique TensorFloweredaf3b32016-10-10 10:26:22 -08003set -e
4set -o pipefail
5
Andrew Selle09045e42016-09-06 08:19:04 -08006# Find out the absolute path to where ./configure resides
A. Unique TensorFlower46d2c282017-01-02 22:19:48 -08007pushd `dirname $0` > /dev/null
Andrew Selle09045e42016-09-06 08:19:04 -08008SOURCE_BASE_DIR=`pwd -P`
9popd > /dev/null
10
Patrick Nguyenc5ab3dd2016-10-20 12:09:18 -080011PLATFORM="$(uname -s | tr 'A-Z' 'a-z')"
Jonathan Hseuc058a012017-01-17 15:06:43 -080012
13function is_linux() {
14 if [[ "${PLATFORM}" == "linux" ]]; then
15 true
16 else
17 false
18 fi
19}
20
21function is_macos() {
22 if [[ "${PLATFORM}" == "darwin" ]]; then
23 true
24 else
25 false
26 fi
27}
28
Patrick Nguyenc5ab3dd2016-10-20 12:09:18 -080029function is_windows() {
30 # On windows, the shell script is actually running in msys
Shanqing Cai56fc8832017-01-23 18:25:25 -080031 if [[ "${PLATFORM}" =~ msys_nt*|mingw*|cygwin*|uwin* ]]; then
Patrick Nguyenc5ab3dd2016-10-20 12:09:18 -080032 true
33 else
34 false
35 fi
36}
37
Dandelion Mané0386a012017-03-10 14:43:23 -080038function sed_hyphen_i() {
39 if is_macos; then
40 sed -i '' "$@"
41 else
42 sed -i "$@"
43 fi
44}
45
A. Unique TensorFlowerccbc8992017-04-04 16:10:08 -080046function write_to_bazelrc() {
47 echo "$1" >> .tf_configure.bazelrc
48}
49
50function write_action_env_to_bazelrc() {
51 write_to_bazelrc "build --action_env $1=\"$2\""
52}
53
A. Unique TensorFlower79789dd2017-04-27 04:47:01 -080054function python_path {
55 "$PYTHON_BIN_PATH" - <<END
56from __future__ import print_function
57import site
58import os
59
60try:
61 input = raw_input
62except NameError:
63 pass
64
65python_paths = []
66if os.getenv('PYTHONPATH') is not None:
67 python_paths = os.getenv('PYTHONPATH').split(':')
68try:
69 library_paths = site.getsitepackages()
70except AttributeError:
71 from distutils.sysconfig import get_python_lib
72 library_paths = [get_python_lib()]
73all_paths = set(python_paths + library_paths)
74
75paths = []
76for path in all_paths:
77 if os.path.isdir(path):
78 paths.append(path)
79
80print(",".join(paths))
81END
82}
83
84function setup_python {
85 ## Set up python-related environment settings:
86 while true; do
87 fromuser=""
88 if [ -z "$PYTHON_BIN_PATH" ]; then
89 default_python_bin_path=$(which python || which python3 || true)
90 read -p "Please specify the location of python. [Default is $default_python_bin_path]: " PYTHON_BIN_PATH
91 fromuser="1"
92 if [ -z "$PYTHON_BIN_PATH" ]; then
93 PYTHON_BIN_PATH=$default_python_bin_path
94 fi
95 fi
96 if [ -e "$PYTHON_BIN_PATH" ]; then
97 break
98 fi
99 echo "Invalid python path. ${PYTHON_BIN_PATH} cannot be found" 1>&2
100 if [ -z "$fromuser" ]; then
101 exit 1
102 fi
103 PYTHON_BIN_PATH=""
104 # Retry
105 done
106
107 if [ -z "$PYTHON_LIB_PATH" ]; then
108 # Split python_path into an array of paths, this allows path containing spaces
109 IFS=','
110 python_lib_path=($(python_path))
111 unset IFS
112
113 if [ 1 = "$USE_DEFAULT_PYTHON_LIB_PATH" ]; then
114 PYTHON_LIB_PATH=${python_lib_path[0]}
115 echo "Using python library path: $PYTHON_LIB_PATH"
116
117 else
118 echo "Found possible Python library paths:"
119 for x in "${python_lib_path[@]}"; do
120 echo " $x"
121 done
122 set -- "${python_lib_path[@]}"
123 echo "Please input the desired Python library path to use. Default is ["$1"]"
124 read b || true
125 if [ "$b" == "" ]; then
126 PYTHON_LIB_PATH=${python_lib_path[0]}
127 echo "Using python library path: $PYTHON_LIB_PATH"
128 else
129 PYTHON_LIB_PATH="$b"
130 fi
131 fi
132 fi
133
134 if [ ! -x "$PYTHON_BIN_PATH" ] || [ -d "$PYTHON_BIN_PATH" ]; then
135 echo "PYTHON_BIN_PATH is not executable. Is it the python binary?"
136 exit 1
137 fi
138
139 local python_major_version=$("${PYTHON_BIN_PATH}" -c 'from __future__ import print_function; import sys; print(sys.version_info[0]);')
140 if [ "$python_major_version" == "" ]; then
141 echo -e "\n\nERROR: Problem getting python version. Is $PYTHON_BIN_PATH the correct python binary?"
142 exit 1
143 fi
144
145 # Convert python path to Windows style before writing into bazel.rc
146 if is_windows; then
147 PYTHON_BIN_PATH="$(cygpath -m "$PYTHON_BIN_PATH")"
148 fi
149
150 # Set-up env variables used by python_configure.bzl
151 write_action_env_to_bazelrc "PYTHON_BIN_PATH" "$PYTHON_BIN_PATH"
152 write_action_env_to_bazelrc "PYTHON_LIB_PATH" "$PYTHON_LIB_PATH"
153 write_to_bazelrc "build --define PYTHON_BIN_PATH=$PYTHON_BIN_PATH"
154 write_to_bazelrc "build --define PYTHON_LIB_PATH=$PYTHON_LIB_PATH"
155 write_to_bazelrc "build --force_python=py$python_major_version"
156 write_to_bazelrc "build --host_force_python=py$python_major_version"
157 write_to_bazelrc "build --python${python_major_version}_path=$PYTHON_BIN_PATH"
158 write_to_bazelrc "test --force_python=py$python_major_version"
159 write_to_bazelrc "test --host_force_python=py$python_major_version"
160 write_to_bazelrc "test --define PYTHON_BIN_PATH=$PYTHON_BIN_PATH"
161 write_to_bazelrc "test --define PYTHON_LIB_PATH=$PYTHON_LIB_PATH"
162 write_to_bazelrc "run --define PYTHON_BIN_PATH=$PYTHON_BIN_PATH"
163 write_to_bazelrc "run --define PYTHON_LIB_PATH=$PYTHON_LIB_PATH"
164
165 # Write tools/python_bin_path.sh
166 echo "export PYTHON_BIN_PATH=\"$PYTHON_BIN_PATH\"" > tools/python_bin_path.sh
167}
168
A. Unique TensorFlowerccbc8992017-04-04 16:10:08 -0800169# This file contains customized config settings.
170rm -f .tf_configure.bazelrc
171touch .tf_configure.bazelrc
172touch .bazelrc
173sed_hyphen_i "/tf_configure/d" .bazelrc
A. Unique TensorFlower82684762017-04-05 11:30:37 -0800174echo "import %workspace%/.tf_configure.bazelrc" >> .bazelrc
A. Unique TensorFlowerccbc8992017-04-04 16:10:08 -0800175
Andrew Harp51dbc462017-01-27 14:42:30 -0800176# Delete any leftover BUILD files from the Makefile build, which would interfere
177# with Bazel parsing.
178MAKEFILE_DOWNLOAD_DIR=tensorflow/contrib/makefile/downloads
179if [ -d "${MAKEFILE_DOWNLOAD_DIR}" ]; then
180 find ${MAKEFILE_DOWNLOAD_DIR} -type f -name '*BUILD' -delete
181fi
182
A. Unique TensorFlower79789dd2017-04-27 04:47:01 -0800183setup_python
Vijay Vasudevanbf6b5362015-12-02 15:04:40 -0800184
Benoit Steiner639b4e72017-02-08 09:25:09 -0800185## Set up MKL related environment settings
186if false; then # Disable building with MKL for now
187 while [ "$TF_NEED_MKL" == "" ]; do
188 fromuser=""
Shanqing Cai32694232017-04-22 06:08:17 -0800189 read -p "Do you wish to build TensorFlow with MKL support (experimental)? [y/N] " INPUT
Benoit Steiner639b4e72017-02-08 09:25:09 -0800190 fromuser="1"
191 case $INPUT in
Shanqing Cai32694232017-04-22 06:08:17 -0800192 [Yy]* ) echo "MKL support (experimental) (will be enabled for TensorFlow"; TF_NEED_MKL=1;;
Benoit Steiner639b4e72017-02-08 09:25:09 -0800193 [Nn]* ) echo "No MKL support will be enabled for TensorFlow"; TF_NEED_MKL=0;;
194 "" ) echo "No MKL support will be enabled for TensorFlow"; TF_NEED_MKL=0;;
195 * ) echo "Invalid selection: " $INPUT;;
196 esac
197 done
198
199 OSNAME=`uname -s`
200
201 if [ "$TF_NEED_MKL" == "1" ]; then # TF_NEED_MKL
202 DST=`dirname $0`
Martin Wickebc456e32017-03-23 12:31:16 -0800203 ARCHIVE_BASENAME=mklml_lnx_2017.0.2.20170209.tgz
204 GITHUB_RELEASE_TAG=v0.5
Benoit Steiner639b4e72017-02-08 09:25:09 -0800205 MKLURL="https://github.com/01org/mkl-dnn/releases/download/$GITHUB_RELEASE_TAG/$ARCHIVE_BASENAME"
206 if ! [ -e "$DST/third_party/mkl/$ARCHIVE_BASENAME" ]; then
207 wget --no-check-certificate -P $DST/third_party/mkl/ $MKLURL
208 fi
209 tar -xzf $DST/third_party/mkl/$ARCHIVE_BASENAME -C $DST/third_party/mkl/
210 extracted_dir_name="${ARCHIVE_BASENAME%.*}"
211 MKL_INSTALL_PATH=$DST/third_party/mkl/$extracted_dir_name
212 MKL_INSTALL_PATH=`${PYTHON_BIN_PATH} -c "import os; print(os.path.realpath(os.path.expanduser('${MKL_INSTALL_PATH}')))"`
213
214 if [ "$OSNAME" == "Linux" ]; then
215 # Full MKL configuration
216 MKL_RT_LIB_PATH="lib/intel64/libmkl_rt.so" #${TF_MKL_EXT}#TODO version?
217 MKL_RT_OMP_LIB_PATH="../compiler/lib/intel64/libiomp5.so" #TODO VERSION?
218
219 # MKL-ML configuration
220 MKL_ML_LIB_PATH="lib/libmklml_intel.so" #${TF_MKL_EXT}#TODO version?
221 MKL_ML_OMP_LIB_PATH="lib/libiomp5.so" #TODO VERSION?
222 elif [ "$OSNAME" == "Darwin" ]; then
223 echo "Darwin is unsupported yet";
224 exit 1
225 fi
226
227 if [ -e "$MKL_INSTALL_PATH/${MKL_ML_LIB_PATH}" ]; then
228 ln -sf $MKL_INSTALL_PATH/${MKL_ML_LIB_PATH} third_party/mkl/
229 ln -sf $MKL_INSTALL_PATH/${MKL_ML_OMP_LIB_PATH} third_party/mkl/
230 ln -sf $MKL_INSTALL_PATH/include third_party/mkl/
231 ln -sf $MKL_INSTALL_PATH/include third_party/eigen3/mkl_include
232 else
233 echo "ERROR: $MKL_INSTALL_PATH/${MKL_ML_LIB_PATH} does not exist";
234 exit 1
235 fi
236
237 if [ -z "$fromuser" ]; then
238 exit 1
239 fi
240
241cat > third_party/mkl/mkl.config <<EOF
242# MKL_INSTALL_PATH refers to the location of MKL root folder. The MKL header and library
243# files can be either in this directory, or under include/ and lib64/
244MKL_INSTALL_PATH=$MKL_INSTALL_PATH
245EOF
246
247 fi # TF_NEED_MKL
248 ################## MKL
249fi # Disable building with MKL for now
250
Martin Wickec4e3d4a2017-01-13 12:20:42 -0800251## Set up architecture-dependent optimization flags.
252if [ -z "$CC_OPT_FLAGS" ]; then
253 default_cc_opt_flags="-march=native"
Benoit Steiner639b4e72017-02-08 09:25:09 -0800254 read -p "Please specify optimization flags to use during compilation when bazel option "\
255"\"--config=opt\" is specified [Default is $default_cc_opt_flags]: " CC_OPT_FLAGS
Martin Wickec4e3d4a2017-01-13 12:20:42 -0800256 if [ -z "$CC_OPT_FLAGS" ]; then
257 CC_OPT_FLAGS=$default_cc_opt_flags
258 fi
259fi
260
Patrick Nguyenc5ab3dd2016-10-20 12:09:18 -0800261if is_windows; then
A. Unique TensorFlower95a954a2016-12-28 13:40:08 -0800262 TF_NEED_GCP=0
Patrick Nguyenc5ab3dd2016-10-20 12:09:18 -0800263 TF_NEED_HDFS=0
Jonathan Hseu83c6e0c2017-01-11 16:39:35 -0800264 TF_NEED_JEMALLOC=0
Benoit Steinera7715982016-11-09 13:14:03 -0800265 TF_NEED_OPENCL=0
A. Unique TensorFlowerccbc8992017-04-04 16:10:08 -0800266 TF_CUDA_CLANG=0
Patrick Nguyenc5ab3dd2016-10-20 12:09:18 -0800267fi
268
Jonathan Hseuc058a012017-01-17 15:06:43 -0800269if is_linux; then
270 while [ "$TF_NEED_JEMALLOC" == "" ]; do
271 read -p "Do you wish to use jemalloc as the malloc implementation? [Y/n] "\
272 INPUT
273 case $INPUT in
274 [Yy]* ) echo "jemalloc enabled"; TF_NEED_JEMALLOC=1;;
275 [Nn]* ) echo "jemalloc disabled"; TF_NEED_JEMALLOC=0;;
276 "" ) echo "jemalloc enabled"; TF_NEED_JEMALLOC=1;;
277 * ) echo "Invalid selection: " $INPUT;;
278 esac
279 done
280else
281 TF_NEED_JEMALLOC=0
282fi
Jonathan Hseu83c6e0c2017-01-11 16:39:35 -0800283
Martin Wickebc456e32017-03-23 12:31:16 -0800284if [[ "$TF_NEED_JEMALLOC" == "1" ]]; then
A. Unique TensorFlowerccbc8992017-04-04 16:10:08 -0800285 write_to_bazelrc 'build --define with_jemalloc=true'
Jonathan Hseu83c6e0c2017-01-11 16:39:35 -0800286fi
287
Martin Wickebc456e32017-03-23 12:31:16 -0800288while [[ "$TF_NEED_GCP" == "" ]]; do
A. Unique TensorFlower95a954a2016-12-28 13:40:08 -0800289 read -p "Do you wish to build TensorFlow with "\
290"Google Cloud Platform support? [y/N] " INPUT
291 case $INPUT in
292 [Yy]* ) echo "Google Cloud Platform support will be enabled for "\
293"TensorFlow"; TF_NEED_GCP=1;;
294 [Nn]* ) echo "No Google Cloud Platform support will be enabled for "\
295"TensorFlow"; TF_NEED_GCP=0;;
296 "" ) echo "No Google Cloud Platform support will be enabled for "\
297"TensorFlow"; TF_NEED_GCP=0;;
298 * ) echo "Invalid selection: " $INPUT;;
299 esac
300done
301
Martin Wickebc456e32017-03-23 12:31:16 -0800302if [[ "$TF_NEED_GCP" == "1" ]]; then
A. Unique TensorFlowerccbc8992017-04-04 16:10:08 -0800303 write_to_bazelrc 'build --define with_gcp_support=true'
A. Unique TensorFlower95a954a2016-12-28 13:40:08 -0800304fi
305
Martin Wickebc456e32017-03-23 12:31:16 -0800306while [[ "$TF_NEED_HDFS" == "" ]]; do
Jonathan Hseu9f5b0982016-09-19 11:14:58 -0800307 read -p "Do you wish to build TensorFlow with "\
308"Hadoop File System support? [y/N] " INPUT
309 case $INPUT in
310 [Yy]* ) echo "Hadoop File System support will be enabled for "\
311"TensorFlow"; TF_NEED_HDFS=1;;
312 [Nn]* ) echo "No Hadoop File System support will be enabled for "\
313"TensorFlow"; TF_NEED_HDFS=0;;
314 "" ) echo "No Hadoop File System support will be enabled for "\
315"TensorFlow"; TF_NEED_HDFS=0;;
316 * ) echo "Invalid selection: " $INPUT;;
317 esac
318done
319
Martin Wickebc456e32017-03-23 12:31:16 -0800320if [[ "$TF_NEED_HDFS" == "1" ]]; then
A. Unique TensorFlowerccbc8992017-04-04 16:10:08 -0800321 write_to_bazelrc 'build --define with_hdfs_support=true'
Jonathan Hseu9f5b0982016-09-19 11:14:58 -0800322fi
323
Peter Hawkins1e67c902017-01-09 12:04:37 -0800324## Enable XLA.
Martin Wickebc456e32017-03-23 12:31:16 -0800325while [[ "$TF_ENABLE_XLA" == "" ]]; do
Peter Hawkins1e67c902017-01-09 12:04:37 -0800326 read -p "Do you wish to build TensorFlow with the XLA just-in-time compiler (experimental)? [y/N] " INPUT
327 case $INPUT in
328 [Yy]* ) echo "XLA JIT support will be enabled for TensorFlow"; TF_ENABLE_XLA=1;;
329 [Nn]* ) echo "No XLA JIT support will be enabled for TensorFlow"; TF_ENABLE_XLA=0;;
330 "" ) echo "No XLA support will be enabled for TensorFlow"; TF_ENABLE_XLA=0;;
331 * ) echo "Invalid selection: " $INPUT;;
332 esac
333done
334
Martin Wickebc456e32017-03-23 12:31:16 -0800335if [[ "$TF_ENABLE_XLA" == "1" ]]; then
A. Unique TensorFlowerccbc8992017-04-04 16:10:08 -0800336 write_to_bazelrc 'build --define with_xla_support=true'
Peter Hawkins1e67c902017-01-09 12:04:37 -0800337fi
338
Shanqing Cai32694232017-04-22 06:08:17 -0800339# Verbs configuration
340while [ "$TF_NEED_VERBS" == "" ]; do
341 read -p "Do you wish to build TensorFlow with "\
342"VERBS support? [y/N] " INPUT
343 case $INPUT in
344 [Yy]* ) echo "VERBS support will be enabled for "\
345"TensorFlow"; TF_NEED_VERBS=1;;
346 [Nn]* ) echo "No VERBS support will be enabled for "\
347"TensorFlow"; TF_NEED_VERBS=0;;
348 "" ) echo "No VERBS support will be enabled for "\
349"TensorFlow"; TF_NEED_VERBS=0;;
350 * ) echo "Invalid selection: " $INPUT;;
351 esac
352done
353
354if [[ "$TF_NEED_VERBS" == "1" ]]; then
355 write_to_bazelrc 'build --define with_verbs_support=true'
356fi
Peter Hawkins1e67c902017-01-09 12:04:37 -0800357
Martin Wickec4e3d4a2017-01-13 12:20:42 -0800358# Append CC optimization flags to bazel.rc
Martin Wickec4e3d4a2017-01-13 12:20:42 -0800359for opt in $CC_OPT_FLAGS; do
A. Unique TensorFloweraaa56002017-05-02 08:25:23 -0800360 write_to_bazelrc 'build:opt --cxxopt=$opt --copt=$opt'
Martin Wickec4e3d4a2017-01-13 12:20:42 -0800361done
362
Andrew Selle09045e42016-09-06 08:19:04 -0800363# Run the gen_git_source to create links where bazel can track dependencies for
364# git hash propagation
365GEN_GIT_SOURCE=tensorflow/tools/git/gen_git_source.py
366chmod a+x ${GEN_GIT_SOURCE}
Patrick Nguyenc5ab3dd2016-10-20 12:09:18 -0800367"${PYTHON_BIN_PATH}" ${GEN_GIT_SOURCE} --configure "${SOURCE_BASE_DIR}"
Andrew Selle09045e42016-09-06 08:19:04 -0800368
Benoit Steinera7715982016-11-09 13:14:03 -0800369## Set up SYCL-related environment settings
370while [ "$TF_NEED_OPENCL" == "" ]; do
371 read -p "Do you wish to build TensorFlow with OpenCL support? [y/N] " INPUT
372 case $INPUT in
373 [Yy]* ) echo "OpenCL support will be enabled for TensorFlow"; TF_NEED_OPENCL=1;;
374 [Nn]* ) echo "No OpenCL support will be enabled for TensorFlow"; TF_NEED_OPENCL=0;;
375 "" ) echo "No OpenCL support will be enabled for TensorFlow"; TF_NEED_OPENCL=0;;
376 * ) echo "Invalid selection: " $INPUT;;
377 esac
378done
379
Manjunath Kudlurf41959c2015-11-06 16:27:58 -0800380## Set up Cuda-related environment settings
381
382while [ "$TF_NEED_CUDA" == "" ]; do
Andrew Harp1cb96892016-12-08 20:05:49 -0800383 read -p "Do you wish to build TensorFlow with CUDA support? [y/N] " INPUT
Manjunath Kudlurf41959c2015-11-06 16:27:58 -0800384 case $INPUT in
Andrew Harp1cb96892016-12-08 20:05:49 -0800385 [Yy]* ) echo "CUDA support will be enabled for TensorFlow"; TF_NEED_CUDA=1;;
386 [Nn]* ) echo "No CUDA support will be enabled for TensorFlow"; TF_NEED_CUDA=0;;
387 "" ) echo "No CUDA support will be enabled for TensorFlow"; TF_NEED_CUDA=0;;
Manjunath Kudlurf41959c2015-11-06 16:27:58 -0800388 * ) echo "Invalid selection: " $INPUT;;
389 esac
390done
391
A. Unique TensorFlower2c598e82016-08-25 10:22:44 -0800392export TF_NEED_CUDA
A. Unique TensorFlowerccbc8992017-04-04 16:10:08 -0800393write_action_env_to_bazelrc "TF_NEED_CUDA" "$TF_NEED_CUDA"
A. Unique TensorFlower8d393ea2017-03-30 07:38:55 -0800394
Rohan Jainaab09972017-01-05 14:39:17 -0800395export TF_NEED_OPENCL
A. Unique TensorFlower82684762017-04-05 11:30:37 -0800396write_action_env_to_bazelrc "TF_NEED_OPENCL" "$TF_NEED_OPENCL"
A. Unique TensorFlower8d393ea2017-03-30 07:38:55 -0800397
Benoit Steinera7715982016-11-09 13:14:03 -0800398if [ "$TF_NEED_CUDA" == "1" ]; then
A. Unique TensorFlower8d393ea2017-03-30 07:38:55 -0800399while [[ "$TF_CUDA_CLANG" == "" ]]; do
400 read -p "Do you want to use clang as CUDA compiler? [y/N] " INPUT
401 case $INPUT in
402 [Yy]* ) echo "Clang will be used as CUDA compiler"; TF_CUDA_CLANG=1;;
403 [Nn]* ) echo "nvcc will be used as CUDA compiler"; TF_CUDA_CLANG=0;;
404 "" ) echo "nvcc will be used as CUDA compiler"; TF_CUDA_CLANG=0;;
405 * ) echo "Invalid selection: " $INPUT;;
406 esac
407done
408
409export TF_CUDA_CLANG
A. Unique TensorFlowerccbc8992017-04-04 16:10:08 -0800410write_action_env_to_bazelrc "TF_CUDA_CLANG" "$TF_CUDA_CLANG"
A. Unique TensorFlower8d393ea2017-03-30 07:38:55 -0800411
Vijay Vasudevan80a5a3e2016-03-29 18:23:11 -0800412# Set up which gcc nvcc should use as the host compiler
Andrew Harp1cb96892016-12-08 20:05:49 -0800413# No need to set this on Windows
A. Unique TensorFlower8d393ea2017-03-30 07:38:55 -0800414while [[ "$TF_CUDA_CLANG" != "1" ]] && ! is_windows && true; do
Vijay Vasudevan80a5a3e2016-03-29 18:23:11 -0800415 fromuser=""
416 if [ -z "$GCC_HOST_COMPILER_PATH" ]; then
A. Unique TensorFloweredaf3b32016-10-10 10:26:22 -0800417 default_gcc_host_compiler_path=$(which gcc || true)
Shanqing Caia81c4f92016-07-22 10:37:35 -0800418 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 Vasudevan80a5a3e2016-03-29 18:23:11 -0800419 fromuser="1"
420 if [ -z "$GCC_HOST_COMPILER_PATH" ]; then
Andrew Harp1cb96892016-12-08 20:05:49 -0800421 GCC_HOST_COMPILER_PATH="$default_gcc_host_compiler_path"
Vijay Vasudevan80a5a3e2016-03-29 18:23:11 -0800422 fi
423 fi
424 if [ -e "$GCC_HOST_COMPILER_PATH" ]; then
A. Unique TensorFlowerb0bdff42016-08-26 12:50:48 -0800425 export GCC_HOST_COMPILER_PATH
A. Unique TensorFlowerccbc8992017-04-04 16:10:08 -0800426 write_action_env_to_bazelrc "GCC_HOST_COMPILER_PATH" "$GCC_HOST_COMPILER_PATH"
Vijay Vasudevan80a5a3e2016-03-29 18:23:11 -0800427 break
428 fi
429 echo "Invalid gcc path. ${GCC_HOST_COMPILER_PATH} cannot be found" 1>&2
430 if [ -z "$fromuser" ]; then
431 exit 1
432 fi
433 GCC_HOST_COMPILER_PATH=""
434 # Retry
435done
436
A. Unique TensorFlower8d393ea2017-03-30 07:38:55 -0800437# Set up which clang we should use as the cuda / host compiler.
438while [[ "$TF_CUDA_CLANG" == "1" ]] && true; do
439 fromuser=""
440 if [ -z "$CLANG_CUDA_COMPILER_PATH" ]; then
441 default_clang_host_compiler_path=$(which clang || true)
442 read -p "Please specify which clang should be used as device and host compiler. [Default is $default_clang_host_compiler_path]: " CLANG_CUDA_COMPILER_PATH
443 fromuser="1"
444 if [ -z "$CLANG_CUDA_COMPILER_PATH" ]; then
445 CLANG_CUDA_COMPILER_PATH="$default_clang_host_compiler_path"
446 fi
447 fi
448 if [ -e "$CLANG_CUDA_COMPILER_PATH" ]; then
449 export CLANG_CUDA_COMPILER_PATH
A. Unique TensorFlowerccbc8992017-04-04 16:10:08 -0800450 write_action_env_to_bazelrc "CLANG_CUDA_COMPILER_PATH" "$CLANG_CUDA_COMPILER_PATH"
A. Unique TensorFlower8d393ea2017-03-30 07:38:55 -0800451 break
452 fi
453 echo "Invalid clang path. ${CLANG_CUDA_COMPILER_PATH} cannot be found" 1>&2
454 if [ -z "$fromuser" ]; then
455 exit 1
456 fi
457 CLANG_CUDA_COMPILER_PATH=""
458 # Retry
459done
460
Manjunath Kudlurf41959c2015-11-06 16:27:58 -0800461# Find out where the CUDA toolkit is installed
462while true; do
A. Unique TensorFlower8a597482016-01-29 09:34:18 -0800463 # Configure the Cuda SDK version to use.
A. Unique TensorFlower8a597482016-01-29 09:34:18 -0800464 if [ -z "$TF_CUDA_VERSION" ]; then
Andrew Harp1cb96892016-12-08 20:05:49 -0800465 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 TensorFlower8a597482016-01-29 09:34:18 -0800466 fi
467
Manjunath Kudlurf41959c2015-11-06 16:27:58 -0800468 fromuser=""
469 if [ -z "$CUDA_TOOLKIT_PATH" ]; then
470 default_cuda_path=/usr/local/cuda
Andrew Harp1cb96892016-12-08 20:05:49 -0800471 if is_windows; then
472 if [ -z "$CUDA_PATH" ]; then
473 default_cuda_path="C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v8.0"
474 else
475 default_cuda_path="$(cygpath -m "$CUDA_PATH")"
476 fi
477 fi
A. Unique TensorFlower8a597482016-01-29 09:34:18 -0800478 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 Kudlurf41959c2015-11-06 16:27:58 -0800479 fromuser="1"
480 if [ -z "$CUDA_TOOLKIT_PATH" ]; then
Andrew Harp1cb96892016-12-08 20:05:49 -0800481 CUDA_TOOLKIT_PATH="$default_cuda_path"
Manjunath Kudlurf41959c2015-11-06 16:27:58 -0800482 fi
483 fi
A. Unique TensorFlower8bf6ef12016-05-05 08:36:05 -0800484
Vijay Vasudevanfe056f02016-02-17 11:42:30 -0800485 if [[ -z "$TF_CUDA_VERSION" ]]; then
486 TF_CUDA_EXT=""
487 else
488 TF_CUDA_EXT=".$TF_CUDA_VERSION"
489 fi
A. Unique TensorFlower8bf6ef12016-05-05 08:36:05 -0800490
Andrew Harp1cb96892016-12-08 20:05:49 -0800491 if is_windows; then
492 CUDA_RT_LIB_PATH="lib/x64/cudart.lib"
Jonathan Hseuc058a012017-01-17 15:06:43 -0800493 elif is_linux; then
A. Unique TensorFlower8bf6ef12016-05-05 08:36:05 -0800494 CUDA_RT_LIB_PATH="lib64/libcudart.so${TF_CUDA_EXT}"
Jonathan Hseuc058a012017-01-17 15:06:43 -0800495 elif is_macos; then
A. Unique TensorFlower8bf6ef12016-05-05 08:36:05 -0800496 CUDA_RT_LIB_PATH="lib/libcudart${TF_CUDA_EXT}.dylib"
497 fi
498
499 if [ -e "${CUDA_TOOLKIT_PATH}/${CUDA_RT_LIB_PATH}" ]; then
A. Unique TensorFlower2c598e82016-08-25 10:22:44 -0800500 export CUDA_TOOLKIT_PATH
A. Unique TensorFlowerccbc8992017-04-04 16:10:08 -0800501 write_action_env_to_bazelrc "CUDA_TOOLKIT_PATH" "$CUDA_TOOLKIT_PATH"
A. Unique TensorFlowerb0bdff42016-08-26 12:50:48 -0800502 export TF_CUDA_VERSION
A. Unique TensorFlowerccbc8992017-04-04 16:10:08 -0800503 write_action_env_to_bazelrc "TF_CUDA_VERSION" "$TF_CUDA_VERSION"
Manjunath Kudlurf41959c2015-11-06 16:27:58 -0800504 break
505 fi
A. Unique TensorFlower8bf6ef12016-05-05 08:36:05 -0800506 echo "Invalid path to CUDA $TF_CUDA_VERSION toolkit. ${CUDA_TOOLKIT_PATH}/${CUDA_RT_LIB_PATH} cannot be found"
507
Manjunath Kudlurf41959c2015-11-06 16:27:58 -0800508 if [ -z "$fromuser" ]; then
509 exit 1
510 fi
Vijay Vasudevanfe056f02016-02-17 11:42:30 -0800511 # Retry
A. Unique TensorFlower8a597482016-01-29 09:34:18 -0800512 TF_CUDA_VERSION=""
Manjunath Kudlurf41959c2015-11-06 16:27:58 -0800513 CUDA_TOOLKIT_PATH=""
Manjunath Kudlurf41959c2015-11-06 16:27:58 -0800514done
515
Martin Wicke916776a2016-01-14 07:30:00 -0800516# Find out where the cuDNN library is installed
Manjunath Kudlurf41959c2015-11-06 16:27:58 -0800517while true; do
A. Unique TensorFlowerccbc8992017-04-04 16:10:08 -0800518 # Configure the cuDNN version to use.
A. Unique TensorFlower8a597482016-01-29 09:34:18 -0800519 if [ -z "$TF_CUDNN_VERSION" ]; then
A. Unique TensorFlowerccbc8992017-04-04 16:10:08 -0800520 read -p "Please specify the cuDNN version you want to use. [Leave empty to use system default]: " TF_CUDNN_VERSION
A. Unique TensorFlower8a597482016-01-29 09:34:18 -0800521 fi
522
Manjunath Kudlurf41959c2015-11-06 16:27:58 -0800523 fromuser=""
524 if [ -z "$CUDNN_INSTALL_PATH" ]; then
525 default_cudnn_path=${CUDA_TOOLKIT_PATH}
A. Unique TensorFlower8a597482016-01-29 09:34:18 -0800526 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 Kudlurf41959c2015-11-06 16:27:58 -0800527 fromuser="1"
528 if [ -z "$CUDNN_INSTALL_PATH" ]; then
529 CUDNN_INSTALL_PATH=$default_cudnn_path
530 fi
531 # Result returned from "read" will be used unexpanded. That make "~" unuseable.
532 # Going through one more level of expansion to handle that.
Andrew Harp1cb96892016-12-08 20:05:49 -0800533 CUDNN_INSTALL_PATH=`"${PYTHON_BIN_PATH}" -c "import os; print(os.path.realpath(os.path.expanduser('${CUDNN_INSTALL_PATH}')))"`
Manjunath Kudlurf41959c2015-11-06 16:27:58 -0800534 fi
A. Unique TensorFlower8bf6ef12016-05-05 08:36:05 -0800535
Vijay Vasudevanfe056f02016-02-17 11:42:30 -0800536 if [[ -z "$TF_CUDNN_VERSION" ]]; then
537 TF_CUDNN_EXT=""
538 else
Benoit Steiner639b4e72017-02-08 09:25:09 -0800539 TF_CUDNN_EXT=".$TF_CUDNN_VERSION"
Vijay Vasudevanfe056f02016-02-17 11:42:30 -0800540 fi
A. Unique TensorFlower8bf6ef12016-05-05 08:36:05 -0800541
Andrew Harp1cb96892016-12-08 20:05:49 -0800542 if is_windows; then
543 CUDA_DNN_LIB_PATH="lib/x64/cudnn.lib"
544 CUDA_DNN_LIB_ALT_PATH="lib/x64/cudnn.lib"
Jonathan Hseuc058a012017-01-17 15:06:43 -0800545 elif is_linux; then
A. Unique TensorFlower8bf6ef12016-05-05 08:36:05 -0800546 CUDA_DNN_LIB_PATH="lib64/libcudnn.so${TF_CUDNN_EXT}"
547 CUDA_DNN_LIB_ALT_PATH="libcudnn.so${TF_CUDNN_EXT}"
Jonathan Hseuc058a012017-01-17 15:06:43 -0800548 elif is_macos; then
Benoit Steiner639b4e72017-02-08 09:25:09 -0800549 CUDA_DNN_LIB_PATH="lib/libcudnn${TF_CUDNN_EXT}.dylib"
550 CUDA_DNN_LIB_ALT_PATH="libcudnn${TF_CUDNN_EXT}.dylib"
A. Unique TensorFlower8bf6ef12016-05-05 08:36:05 -0800551 fi
552
553 if [ -e "$CUDNN_INSTALL_PATH/${CUDA_DNN_LIB_ALT_PATH}" -o -e "$CUDNN_INSTALL_PATH/${CUDA_DNN_LIB_PATH}" ]; then
A. Unique TensorFlowerb0bdff42016-08-26 12:50:48 -0800554 export TF_CUDNN_VERSION
A. Unique TensorFlowerccbc8992017-04-04 16:10:08 -0800555 write_action_env_to_bazelrc "TF_CUDNN_VERSION" "$TF_CUDNN_VERSION"
A. Unique TensorFlower2c598e82016-08-25 10:22:44 -0800556 export CUDNN_INSTALL_PATH
A. Unique TensorFlowerccbc8992017-04-04 16:10:08 -0800557 write_action_env_to_bazelrc "CUDNN_INSTALL_PATH" "$CUDNN_INSTALL_PATH"
Eugene Brevdo56f1d642016-03-10 17:18:30 -0800558 break
559 fi
A. Unique TensorFlower8bf6ef12016-05-05 08:36:05 -0800560
Jonathan Hseuc058a012017-01-17 15:06:43 -0800561 if is_linux; then
Vijay Vasudevan93a975e2017-02-17 17:05:49 -0800562 if ! type ldconfig > /dev/null 2>&1; then
563 LDCONFIG_BIN=/sbin/ldconfig
564 else
565 LDCONFIG_BIN=ldconfig
566 fi
567 CUDNN_PATH_FROM_LDCONFIG="$($LDCONFIG_BIN -p | sed -n 's/.*libcudnn.so .* => \(.*\)/\1/p')"
A. Unique TensorFlower8bf6ef12016-05-05 08:36:05 -0800568 if [ -e "${CUDNN_PATH_FROM_LDCONFIG}${TF_CUDNN_EXT}" ]; then
A. Unique TensorFlowerb0bdff42016-08-26 12:50:48 -0800569 export TF_CUDNN_VERSION
A. Unique TensorFlowerccbc8992017-04-04 16:10:08 -0800570 write_action_env_to_bazelrc "TF_CUDNN_VERSION" "$TF_CUDNN_VERSION"
A. Unique TensorFlower2c598e82016-08-25 10:22:44 -0800571 export CUDNN_INSTALL_PATH="$(dirname ${CUDNN_PATH_FROM_LDCONFIG})"
A. Unique TensorFlowerccbc8992017-04-04 16:10:08 -0800572 write_action_env_to_bazelrc "CUDNN_INSTALL_PATH" "$CUDNN_INSTALL_PATH"
A. Unique TensorFlower8bf6ef12016-05-05 08:36:05 -0800573 break
574 fi
Manjunath Kudlurf41959c2015-11-06 16:27:58 -0800575 fi
A. Unique TensorFlower8bf6ef12016-05-05 08:36:05 -0800576 echo "Invalid path to cuDNN ${CUDNN_VERSION} toolkit. Neither of the following two files can be found:"
577 echo "${CUDNN_INSTALL_PATH}/${CUDA_DNN_LIB_PATH}"
578 echo "${CUDNN_INSTALL_PATH}/${CUDA_DNN_LIB_ALT_PATH}"
Jonathan Hseuc058a012017-01-17 15:06:43 -0800579 if is_linux; then
A. Unique TensorFlower8bf6ef12016-05-05 08:36:05 -0800580 echo "${CUDNN_PATH_FROM_LDCONFIG}${TF_CUDNN_EXT}"
581 fi
582
Manjunath Kudlurf41959c2015-11-06 16:27:58 -0800583 if [ -z "$fromuser" ]; then
584 exit 1
585 fi
Vijay Vasudevanfe056f02016-02-17 11:42:30 -0800586 # Retry
A. Unique TensorFlower8a597482016-01-29 09:34:18 -0800587 TF_CUDNN_VERSION=""
Manjunath Kudlurf41959c2015-11-06 16:27:58 -0800588 CUDNN_INSTALL_PATH=""
Manjunath Kudlurf41959c2015-11-06 16:27:58 -0800589done
590
Vijay Vasudevanfe056f02016-02-17 11:42:30 -0800591# Configure the compute capabilities that TensorFlow builds for.
592# Since Cuda toolkit is not backward-compatible, this is not guaranteed to work.
593while true; do
594 fromuser=""
A. Unique TensorFlower2c598e82016-08-25 10:22:44 -0800595 default_cuda_compute_capabilities="3.5,5.2"
Vijay Vasudevanfe056f02016-02-17 11:42:30 -0800596 if [ -z "$TF_CUDA_COMPUTE_CAPABILITIES" ]; then
Vijay Vasudevan4dffee72015-11-12 11:27:00 -0800597cat << EOF
598Please specify a list of comma-separated Cuda compute capabilities you want to build with.
599You can find the compute capability of your device at: https://developer.nvidia.com/cuda-gpus.
600Please note that each additional compute capability significantly increases your build time and binary size.
601EOF
Vijay Vasudevanfe056f02016-02-17 11:42:30 -0800602 read -p "[Default is: \"3.5,5.2\"]: " TF_CUDA_COMPUTE_CAPABILITIES
603 fromuser=1
604 fi
A. Unique TensorFlower2c598e82016-08-25 10:22:44 -0800605 if [ -z "$TF_CUDA_COMPUTE_CAPABILITIES" ]; then
606 TF_CUDA_COMPUTE_CAPABILITIES=$default_cuda_compute_capabilities
607 fi
Vijay Vasudevanfe056f02016-02-17 11:42:30 -0800608 # Check whether all capabilities from the input is valid
609 COMPUTE_CAPABILITIES=${TF_CUDA_COMPUTE_CAPABILITIES//,/ }
610 ALL_VALID=1
611 for CAPABILITY in $COMPUTE_CAPABILITIES; do
612 if [[ ! "$CAPABILITY" =~ [0-9]+.[0-9]+ ]]; then
613 echo "Invalid compute capability: " $CAPABILITY
614 ALL_VALID=0
Vijay Vasudevan4dffee72015-11-12 11:27:00 -0800615 break
616 fi
Vijay Vasudevan4dffee72015-11-12 11:27:00 -0800617 done
Vijay Vasudevanfe056f02016-02-17 11:42:30 -0800618 if [ "$ALL_VALID" == "0" ]; then
619 if [ -z "$fromuser" ]; then
620 exit 1
621 fi
622 else
A. Unique TensorFlowerb0bdff42016-08-26 12:50:48 -0800623 export TF_CUDA_COMPUTE_CAPABILITIES
A. Unique TensorFlowerccbc8992017-04-04 16:10:08 -0800624 write_action_env_to_bazelrc "TF_CUDA_COMPUTE_CAPABILITIES" "$TF_CUDA_COMPUTE_CAPABILITIES"
Vijay Vasudevanfe056f02016-02-17 11:42:30 -0800625 break
Vijay Vasudevan4dffee72015-11-12 11:27:00 -0800626 fi
Vijay Vasudevanfe056f02016-02-17 11:42:30 -0800627 TF_CUDA_COMPUTE_CAPABILITIES=""
628done
Vijay Vasudevan4dffee72015-11-12 11:27:00 -0800629
Andrew Harp1cb96892016-12-08 20:05:49 -0800630if is_windows; then
631 # The following three variables are needed for MSVC toolchain configuration in Bazel
632 export CUDA_PATH="$CUDA_TOOLKIT_PATH"
633 export CUDA_COMPUTE_CAPABILITIES="$TF_CUDA_COMPUTE_CAPABILITIES"
634 export NO_WHOLE_ARCHIVE_OPTION=1
A. Unique TensorFlowerccbc8992017-04-04 16:10:08 -0800635 write_action_env_to_bazelrc "CUDA_PATH" "$CUDA_PATH"
636 write_action_env_to_bazelrc "CUDA_COMPUTE_CAPABILITIES" "$CUDA_COMPUTE_CAPABILITIES"
637 write_action_env_to_bazelrc "NO_WHOLE_ARCHIVE_OPTION" "1"
Andrew Harp1cb96892016-12-08 20:05:49 -0800638fi
639
Benoit Steinera7715982016-11-09 13:14:03 -0800640# end of if "$TF_NEED_CUDA" == "1"
641fi
642
643# OpenCL configuration
644
645if [ "$TF_NEED_OPENCL" == "1" ]; then
646
647# Determine which C++ compiler should be used as the host compiler
648while true; do
649 fromuser=""
650 if [ -z "$HOST_CXX_COMPILER" ]; then
Jonathan Hseubed83832016-12-22 15:38:30 -0800651 default_cxx_host_compiler=$(which clang++-3.6 || true)
Benoit Steinera7715982016-11-09 13:14:03 -0800652 read -p "Please specify which C++ compiler should be used as the host C++ compiler. [Default is $default_cxx_host_compiler]: " HOST_CXX_COMPILER
653 fromuser="1"
654 if [ -z "$HOST_CXX_COMPILER" ]; then
655 HOST_CXX_COMPILER=$default_cxx_host_compiler
656 fi
657 fi
658 if [ -e "$HOST_CXX_COMPILER" ]; then
659 export HOST_CXX_COMPILER
A. Unique TensorFlower82684762017-04-05 11:30:37 -0800660 write_action_env_to_bazelrc "HOST_CXX_COMPILER" "$HOST_CXX_COMPILER"
Benoit Steinera7715982016-11-09 13:14:03 -0800661 break
662 fi
663 echo "Invalid C++ compiler path. ${HOST_CXX_COMPILER} cannot be found" 1>&2
664 if [ -z "$fromuser" ]; then
665 exit 1
666 fi
667 HOST_CXX_COMPILER=""
668 # Retry
669done
670
671# Determine which C compiler should be used as the host compiler
672while true; do
673 fromuser=""
674 if [ -z "$HOST_C_COMPILER" ]; then
Jonathan Hseubed83832016-12-22 15:38:30 -0800675 default_c_host_compiler=$(which clang-3.6 || true)
Benoit Steinera7715982016-11-09 13:14:03 -0800676 read -p "Please specify which C compiler should be used as the host C compiler. [Default is $default_c_host_compiler]: " HOST_C_COMPILER
677 fromuser="1"
678 if [ -z "$HOST_C_COMPILER" ]; then
679 HOST_C_COMPILER=$default_c_host_compiler
680 fi
681 fi
682 if [ -e "$HOST_C_COMPILER" ]; then
683 export HOST_C_COMPILER
A. Unique TensorFlower82684762017-04-05 11:30:37 -0800684 write_action_env_to_bazelrc "HOST_C_COMPILER" "$HOST_C_COMPILER"
Benoit Steinera7715982016-11-09 13:14:03 -0800685 break
686 fi
687 echo "Invalid C compiler path. ${HOST_C_COMPILER} cannot be found" 1>&2
688 if [ -z "$fromuser" ]; then
689 exit 1
690 fi
691 HOST_C_COMPILER=""
692 # Retry
693done
694
695while true; do
696 # Configure the OPENCL version to use.
697 TF_OPENCL_VERSION="1.2"
698
699 # Point to ComputeCpp root
700 if [ -z "$COMPUTECPP_TOOLKIT_PATH" ]; then
701 default_computecpp_toolkit_path=/usr/local/computecpp
Martin Wicke2e4869a2016-12-14 15:46:53 -0800702 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 Steinera7715982016-11-09 13:14:03 -0800703 fromuser="1"
704 if [ -z "$COMPUTECPP_TOOLKIT_PATH" ]; then
705 COMPUTECPP_TOOLKIT_PATH=$default_computecpp_toolkit_path
706 fi
707 fi
708
Jonathan Hseuc058a012017-01-17 15:06:43 -0800709 if is_linux; then
Benoit Steinera7715982016-11-09 13:14:03 -0800710 SYCL_RT_LIB_PATH="lib/libComputeCpp.so"
711 fi
712
713 if [ -e "${COMPUTECPP_TOOLKIT_PATH}/${SYCL_RT_LIB_PATH}" ]; then
714 export COMPUTECPP_TOOLKIT_PATH
A. Unique TensorFlower82684762017-04-05 11:30:37 -0800715 write_action_env_to_bazelrc "COMPUTECPP_TOOLKIT_PATH" "$COMPUTECPP_TOOLKIT_PATH"
Benoit Steinera7715982016-11-09 13:14:03 -0800716 break
717 fi
718 echo "Invalid SYCL $TF_OPENCL_VERSION library path. ${COMPUTECPP_TOOLKIT_PATH}/${SYCL_RT_LIB_PATH} cannot be found"
719
720 if [ -z "$fromuser" ]; then
721 exit 1
722 fi
723 # Retry
724 TF_OPENCL_VERSION=""
725 COMPUTECPP_TOOLKIT_PATH=""
726done
727
Benoit Steinera7715982016-11-09 13:14:03 -0800728# end of if "$TF_NEED_OPENCL" == "1"
729fi
730
A. Unique TensorFlowerccbc8992017-04-04 16:10:08 -0800731# TODO(gunan): Remove once bazel correctly handles changes in remote repositories.
732bazel clean
Manjunath Kudlurf41959c2015-11-06 16:27:58 -0800733echo "Configuration finished"