#!/bin/bash ## Set up python-related environment settings while true; do fromuser="" if [ -z "$PYTHON_BIN_PATH" ]; then default_python_bin_path=$(which python) read -p "Please specify the location of python. [Default is $default_python_bin_path]: " PYTHON_BIN_PATH fromuser="1" if [ -z "$PYTHON_BIN_PATH" ]; then PYTHON_BIN_PATH=$default_python_bin_path fi fi if [ -e "$PYTHON_BIN_PATH" ]; then break fi echo "Invalid python path. ${PYTHON_BIN_PATH} cannot be found" 1>&2 if [ -z "$fromuser" ]; then exit 1 fi PYTHON_BIN_PATH="" # Retry done # Invoke python_config and set up symlinks to python includes (./util/python/python_config.sh --setup "$PYTHON_BIN_PATH";) || exit -1 ## Set up Cuda-related environment settings while [ "$TF_NEED_CUDA" == "" ]; do read -p "Do you wish to build TensorFlow with GPU support? [y/N] " INPUT case $INPUT in [Yy]* ) echo "GPU support will be enabled for TensorFlow"; TF_NEED_CUDA=1;; [Nn]* ) echo "No GPU support will be enabled for TensorFlow"; TF_NEED_CUDA=0;; "" ) echo "No GPU support will be enabled for TensorFlow"; TF_NEED_CUDA=0;; * ) echo "Invalid selection: " $INPUT;; esac done if [ "$TF_NEED_CUDA" == "0" ]; then echo "Configuration finished" exit fi # Find out where the CUDA toolkit is installed while true; do # Configure the Cuda SDK version to use. if [ -z "$TF_CUDA_VERSION" ]; then 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 fi fromuser="" if [ -z "$CUDA_TOOLKIT_PATH" ]; then default_cuda_path=/usr/local/cuda 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 fromuser="1" if [ -z "$CUDA_TOOLKIT_PATH" ]; then CUDA_TOOLKIT_PATH=$default_cuda_path fi fi if [[ -z "$TF_CUDA_VERSION" ]]; then TF_CUDA_EXT="" else TF_CUDA_EXT=".$TF_CUDA_VERSION" fi if [ -e $CUDA_TOOLKIT_PATH/lib64/libcudart.so$TF_CUDA_EXT ]; then break fi echo "Invalid path to CUDA $TF_CUDA_VERSION toolkit. $CUDA_TOOLKIT_PATH/lib64/libcudart.so$TF_CUDA_EXT cannot be found" if [ -z "$fromuser" ]; then exit 1 fi # Retry TF_CUDA_VERSION="" CUDA_TOOLKIT_PATH="" done # Find out where the cuDNN library is installed while true; do # Configure the Cudnn version to use. if [ -z "$TF_CUDNN_VERSION" ]; then read -p "Please specify the Cudnn version you want to use. [Leave empty to use system default]: " TF_CUDNN_VERSION fi fromuser="" if [ -z "$CUDNN_INSTALL_PATH" ]; then default_cudnn_path=${CUDA_TOOLKIT_PATH} 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 fromuser="1" if [ -z "$CUDNN_INSTALL_PATH" ]; then CUDNN_INSTALL_PATH=$default_cudnn_path fi # Result returned from "read" will be used unexpanded. That make "~" unuseable. # Going through one more level of expansion to handle that. CUDNN_INSTALL_PATH=$(bash -c "readlink -f $CUDNN_INSTALL_PATH") fi if [[ -z "$TF_CUDNN_VERSION" ]]; then TF_CUDNN_EXT="" else TF_CUDNN_EXT=".$TF_CUDNN_VERSION" fi if [ -e "$CUDNN_INSTALL_PATH/libcudnn.so${TF_CUDNN_EXT}" -o -e "$CUDNN_INSTALL_PATH/lib64/libcudnn.so${TF_CUDNN_EXT}" ]; then break fi CUDNN_PATH_FROM_LDCONFIG="$(ldconfig -p | sed -n 's/.*libcudnn.so .* => \(.*\)/\1/p')" if [ -e "${CUDNN_PATH_FROM_LDCONFIG}${TF_CUDNN_EXT}" ]; then CUDNN_INSTALL_PATH="$(dirname ${CUDNN_PATH_FROM_LDCONFIG})" break fi echo "Invalid path to cuDNN ${TF_CUDNN_VERSION} toolkit. Neither of the following two files can be found:" echo "$CUDNN_INSTALL_PATH/lib64/libcudnn.so${TF_CUDNN_EXT}" echo "$CUDNN_INSTALL_PATH/libcudnn.so${TF_CUDNN_EXT}" echo "${CUDNN_PATH_FROM_LDCONFIG}${TF_CUDNN_EXT}" if [ -z "$fromuser" ]; then exit 1 fi # Retry TF_CUDNN_VERSION="" CUDNN_INSTALL_PATH="" done cat > third_party/gpus/cuda/cuda.config <