@@ -80,6 +80,7 @@ while [ "$TF_NEED_CUDA" == "" ]; do
8080 esac
8181done
8282
83+ export TF_NEED_CUDA
8384if [ " $TF_NEED_CUDA " == " 0" ]; then
8485 echo " Configuration finished"
8586 exit
@@ -97,6 +98,7 @@ while true; do
9798 fi
9899 fi
99100 if [ -e " $GCC_HOST_COMPILER_PATH " ]; then
101+ export CC=$GCC_HOST_COMPILER_PATH
100102 break
101103 fi
102104 echo " Invalid gcc path. ${GCC_HOST_COMPILER_PATH} cannot be found" 1>&2
@@ -107,7 +109,6 @@ while true; do
107109 # Retry
108110done
109111
110-
111112# Find out where the CUDA toolkit is installed
112113OSNAME=` uname -s`
113114
@@ -140,6 +141,8 @@ while true; do
140141 fi
141142
142143 if [ -e " ${CUDA_TOOLKIT_PATH} /${CUDA_RT_LIB_PATH} " ]; then
144+ export CUDA_TOOLKIT_PATH
145+ export CUDA_VERSION=$TF_CUDA_VERSION
143146 break
144147 fi
145148 echo " Invalid path to CUDA $TF_CUDA_VERSION toolkit. ${CUDA_TOOLKIT_PATH} /${CUDA_RT_LIB_PATH} cannot be found"
@@ -200,13 +203,16 @@ while true; do
200203 fi
201204
202205 if [ -e " $CUDNN_INSTALL_PATH /${CUDA_DNN_LIB_ALT_PATH} " -o -e " $CUDNN_INSTALL_PATH /${CUDA_DNN_LIB_PATH} " ]; then
206+ export CUDNN_VERSION=$TF_CUDNN_VERSION
207+ export CUDNN_INSTALL_PATH
203208 break
204209 fi
205210
206211 if [ " $OSNAME " == " Linux" ]; then
207212 CUDNN_PATH_FROM_LDCONFIG=" $( ldconfig -p | sed -n ' s/.*libcudnn.so .* => \(.*\)/\1/p' ) "
208213 if [ -e " ${CUDNN_PATH_FROM_LDCONFIG}${TF_CUDNN_EXT} " ]; then
209- CUDNN_INSTALL_PATH=" $( dirname ${CUDNN_PATH_FROM_LDCONFIG} ) "
214+ export CUDNN_VERSION=$TF_CUDNN_VERSION
215+ export CUDNN_INSTALL_PATH=" $( dirname ${CUDNN_PATH_FROM_LDCONFIG} ) "
210216 break
211217 fi
212218 fi
@@ -225,42 +231,11 @@ while true; do
225231 CUDNN_INSTALL_PATH=" "
226232done
227233
228- cat > third_party/gpus/cuda/cuda.config << EOF
229- # CUDA_TOOLKIT_PATH refers to the CUDA toolkit.
230- CUDA_TOOLKIT_PATH="$CUDA_TOOLKIT_PATH "
231- # CUDNN_INSTALL_PATH refers to the cuDNN toolkit. The cuDNN header and library
232- # files can be either in this directory, or under include/ and lib64/
233- # directories separately.
234- CUDNN_INSTALL_PATH="$CUDNN_INSTALL_PATH "
235-
236- # The Cuda SDK version that should be used in this build (empty to use libcudart.so symlink)
237- TF_CUDA_VERSION=$TF_CUDA_VERSION
238-
239- # The Cudnn version that should be used in this build
240- TF_CUDNN_VERSION=$TF_CUDNN_VERSION
241- EOF
242-
243- # Configure the gcc host compiler to use
244- export WARNING=$DO_NOT_SUBMIT_WARNING
245- 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
246- 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
247-
248- # Configure the platform name.
249- perl -pi -e " s,PLATFORM = \" .*\" ,PLATFORM = \" $OSNAME \" ,s" third_party/gpus/cuda/platform.bzl
250-
251- # Configure the Cuda toolkit version to work with.
252- perl -pi -e " s,(GetCudaVersion.*return )\" [0-9\.]*\" ,\1\" $TF_CUDA_VERSION \" ,s" tensorflow/stream_executor/dso_loader.cc
253- perl -pi -e " s,CUDA_VERSION = \" [0-9\.]*\" ,CUDA_VERSION = \" $TF_CUDA_VERSION \" ,s" third_party/gpus/cuda/platform.bzl
254-
255- # Configure the Cudnn version to work with.
256- perl -pi -e " s,(GetCudnnVersion.*return )\" [0-9\.]*\" ,\1\" $TF_CUDNN_VERSION \" ,s" tensorflow/stream_executor/dso_loader.cc
257- perl -pi -e " s,CUDNN_VERSION = \" [0-9\.]*\" ,CUDNN_VERSION = \" $TF_CUDNN_VERSION \" ,s" third_party/gpus/cuda/platform.bzl
258-
259-
260234# Configure the compute capabilities that TensorFlow builds for.
261235# Since Cuda toolkit is not backward-compatible, this is not guaranteed to work.
262236while true ; do
263237 fromuser=" "
238+ default_cuda_compute_capabilities=" 3.5,5.2"
264239 if [ -z " $TF_CUDA_COMPUTE_CAPABILITIES " ]; then
265240cat << EOF
266241Please specify a list of comma-separated Cuda compute capabilities you want to build with.
270245 read -p " [Default is: \" 3.5,5.2\" ]: " TF_CUDA_COMPUTE_CAPABILITIES
271246 fromuser=1
272247 fi
248+ if [ -z " $TF_CUDA_COMPUTE_CAPABILITIES " ]; then
249+ TF_CUDA_COMPUTE_CAPABILITIES=$default_cuda_compute_capabilities
250+ fi
273251 # Check whether all capabilities from the input is valid
274252 COMPUTE_CAPABILITIES=${TF_CUDA_COMPUTE_CAPABILITIES// ,/ }
275253 ALL_VALID=1
@@ -285,34 +263,13 @@ EOF
285263 exit 1
286264 fi
287265 else
266+ export CUDA_COMPUTE_CAPABILITIES=$TF_CUDA_COMPUTE_CAPABILITIES
288267 break
289268 fi
290269 TF_CUDA_COMPUTE_CAPABILITIES=" "
291270done
292271
293- if [ ! -z " $TF_CUDA_COMPUTE_CAPABILITIES " ]; then
294- export WARNING=$DO_NOT_SUBMIT_WARNING
295- function CudaGenCodeOpts() {
296- OUTPUT=" "
297- for CAPABILITY in $@ ; do
298- OUTPUT=${OUTPUT} " \" ${CAPABILITY} \" , "
299- done
300- echo $OUTPUT
301- }
302- export CUDA_GEN_CODES_OPTS=$( CudaGenCodeOpts ${TF_CUDA_COMPUTE_CAPABILITIES// ,/ } )
303- 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
304- function CudaVersionOpts() {
305- OUTPUT=" "
306- for CAPABILITY in $@ ; do
307- OUTPUT=$OUTPUT " CudaVersion(\" ${CAPABILITY} \" ), "
308- done
309- echo $OUTPUT
310- }
311- export CUDA_VERSION_OPTS=$( CudaVersionOpts ${TF_CUDA_COMPUTE_CAPABILITIES// ,/ } )
312- 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
313- fi
314-
315- # Invoke the cuda_config.sh and set up the TensorFlow's canonical view of the Cuda libraries
316- (cd third_party/gpus/cuda; ./cuda_config.sh; ) || exit -1
272+ bazel clean --expunge
273+ bazel fetch //...
317274
318275echo " Configuration finished"
0 commit comments