github.com/johnnyeven/libtools@v0.0.0-20191126065708-61829c1adf46/tools/tf_env_collect.sh (about) 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 17 set -u # Check for undefined variables 18 19 die() { 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 29 echo "Collecting system information..." 30 31 OUTPUT_FILE=tf_env.txt 32 python_bin_path=$(which python || which python3 || die "Cannot find Python binary") 33 34 { 35 echo 36 echo '== check python ===================================================' 37 } >> ${OUTPUT_FILE} 38 39 cat <<EOF > /tmp/check_python.py 40 import platform 41 42 print("""python version: %s 43 python branch: %s 44 python build version: %s 45 python compiler version: %s 46 python implementation: %s 47 """ % ( 48 platform.python_version(), 49 platform.python_branch(), 50 platform.python_build(), 51 platform.python_compiler(), 52 platform.python_implementation(), 53 )) 54 EOF 55 ${python_bin_path} /tmp/check_python.py 2>&1 >> ${OUTPUT_FILE} 56 57 { 58 echo 59 echo '== check os platform ===============================================' 60 } >> ${OUTPUT_FILE} 61 62 cat <<EOF > /tmp/check_os.py 63 import platform 64 65 print("""os: %s 66 os kernel version: %s 67 os release version: %s 68 os platform: %s 69 linux distribution: %s 70 linux os distribution: %s 71 mac version: %s 72 uname: %s 73 architecture: %s 74 machine: %s 75 """ % ( 76 platform.system(), 77 platform.version(), 78 platform.release(), 79 platform.platform(), 80 platform.linux_distribution(), 81 platform.dist(), 82 platform.mac_ver(), 83 platform.uname(), 84 platform.architecture(), 85 platform.machine(), 86 )) 87 EOF 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 117 cat <<EOF > /tmp/check_tf.py 118 import tensorflow as tf; 119 print("tf.version.VERSION = %s" % tf.version.VERSION) 120 print("tf.version.GIT_VERSION = %s" % tf.version.GIT_VERSION) 121 print("tf.version.COMPILER_VERSION = %s" % tf.version.COMPILER_VERSION) 122 with tf.Session() as sess: 123 print("Sanity check: %r" % sess.run(tf.constant([1,2,3])[:1])) 124 EOF 125 ${python_bin_path} /tmp/check_tf.py 2>&1 >> ${OUTPUT_FILE} 126 127 LD_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 153 find /usr/local -type f -name 'libcudart*' 2>/dev/null | grep cuda | grep -v "\\.cache" >> ${OUTPUT_FILE} 154 find /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. 172 mv $OUTPUT_FILE old-$OUTPUT_FILE 173 grep -v -i google old-${OUTPUT_FILE} > $OUTPUT_FILE 174 175 echo "Wrote environment to ${OUTPUT_FILE}. You can review the contents of that file." 176 echo "and use it to populate the fields in the github issue template." 177 echo 178 echo "cat ${OUTPUT_FILE}" 179 echo 180