1#!/usr/bin/env bash 2# Copyright 2017 The TensorFlow Authors. All Rights Reserved. 3# 4# Licensed under the Apache License, Version 2.0 (the "License"); 5# you may not use this file except in compliance with the License. 6# You may obtain a copy of the License at 7# 8# http://www.apache.org/licenses/LICENSE-2.0 9# 10# Unless required by applicable law or agreed to in writing, software 11# distributed under the License is distributed on an "AS IS" BASIS, 12# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13# See the License for the specific language governing permissions and 14# limitations under the License. 15# ============================================================================== 16 17set -u # Check for undefined variables 18 19die() { 20 # Print a message and exit with code 1. 21 # 22 # Usage: die <error_message> 23 # e.g., die "Something bad happened." 24 25 echo $@ 26 exit 1 27} 28 29echo "Collecting system information..." 30 31OUTPUT_FILE=tf_env.txt 32python_bin_path=$(which python || which python3 || die "Cannot find Python binary") 33 34{ 35echo 36echo '== check python ===================================================' 37} >> ${OUTPUT_FILE} 38 39cat <<EOF > /tmp/check_python.py 40import platform 41 42print("""python version: %s 43python branch: %s 44python build version: %s 45python compiler version: %s 46python implementation: %s 47""" % ( 48platform.python_version(), 49platform.python_branch(), 50platform.python_build(), 51platform.python_compiler(), 52platform.python_implementation(), 53)) 54EOF 55${python_bin_path} /tmp/check_python.py 2>&1 >> ${OUTPUT_FILE} 56 57{ 58echo 59echo '== check os platform ===============================================' 60} >> ${OUTPUT_FILE} 61 62cat <<EOF > /tmp/check_os.py 63import platform 64 65print("""os: %s 66os kernel version: %s 67os release version: %s 68os platform: %s 69linux distribution: %s 70linux os distribution: %s 71mac version: %s 72uname: %s 73architecture: %s 74machine: %s 75""" % ( 76platform.system(), 77platform.version(), 78platform.release(), 79platform.platform(), 80platform.linux_distribution(), 81platform.dist(), 82platform.mac_ver(), 83platform.uname(), 84platform.architecture(), 85platform.machine(), 86)) 87EOF 88${python_bin_path} /tmp/check_os.py 2>&1 >> ${OUTPUT_FILE} 89 90{ 91 echo 92 echo '== are we in docker =============================================' 93 num=`cat /proc/1/cgroup | grep docker | wc -l`; 94 if [ $num -ge 1 ]; then 95 echo "Yes" 96 else 97 echo "No" 98 fi 99 100 echo 101 echo '== compiler =====================================================' 102 c++ --version 2>&1 103 104 echo 105 echo '== check pips ===================================================' 106 pip list 2>&1 | grep "proto\|numpy\|tensorflow" 107 108 109 echo 110 echo '== check for virtualenv =========================================' 111 ${python_bin_path} -c "import sys;print(hasattr(sys, \"real_prefix\"))" 112 113 echo 114 echo '== tensorflow import ============================================' 115} >> ${OUTPUT_FILE} 116 117cat <<EOF > /tmp/check_tf.py 118import tensorflow as tf; 119print("tf.version.VERSION = %s" % tf.version.VERSION) 120print("tf.version.GIT_VERSION = %s" % tf.version.GIT_VERSION) 121print("tf.version.COMPILER_VERSION = %s" % tf.version.COMPILER_VERSION) 122with tf.Session() as sess: 123 print("Sanity check: %r" % sess.run(tf.constant([1,2,3])[:1])) 124EOF 125${python_bin_path} /tmp/check_tf.py 2>&1 >> ${OUTPUT_FILE} 126 127LD_DEBUG=libs ${python_bin_path} -c "import tensorflow" 2>>${OUTPUT_FILE} > /tmp/loadedlibs 128 129{ 130 grep libcudnn.so /tmp/loadedlibs 131 echo 132 echo '== env ==========================================================' 133 if [ -z ${LD_LIBRARY_PATH+x} ]; then 134 echo "LD_LIBRARY_PATH is unset"; 135 else 136 echo LD_LIBRARY_PATH ${LD_LIBRARY_PATH} ; 137 fi 138 if [ -z ${DYLD_LIBRARY_PATH+x} ]; then 139 echo "DYLD_LIBRARY_PATH is unset"; 140 else 141 echo DYLD_LIBRARY_PATH ${DYLD_LIBRARY_PATH} ; 142 fi 143 144 145 echo 146 echo '== nvidia-smi ===================================================' 147 nvidia-smi 2>&1 148 149 echo 150 echo '== cuda libs ===================================================' 151} >> ${OUTPUT_FILE} 152 153find /usr/local -type f -name 'libcudart*' 2>/dev/null | grep cuda | grep -v "\\.cache" >> ${OUTPUT_FILE} 154find /usr/local -type f -name 'libudnn*' 2>/dev/null | grep cuda | grep -v "\\.cache" >> ${OUTPUT_FILE} 155 156{ 157 echo 158 echo '== tensorflow installed from info ==================' 159 pip show tensorflow 160 161 echo 162 echo '== python version ==============================================' 163 echo '(major, minor, micro, releaselevel, serial)' 164 python -c 'import sys; print(sys.version_info[:])' 165 166 echo 167 echo '== bazel version ===============================================' 168 bazel version 169} >> ${OUTPUT_FILE} 170 171# Remove any words with google. 172mv $OUTPUT_FILE old-$OUTPUT_FILE 173grep -v -i google old-${OUTPUT_FILE} > $OUTPUT_FILE 174 175echo "Wrote environment to ${OUTPUT_FILE}. You can review the contents of that file." 176echo "and use it to populate the fields in the github issue template." 177echo 178echo "cat ${OUTPUT_FILE}" 179echo 180 181