| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 005a88f commit 008910f
99 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -22,7 +22,9 @@ networks research. The system is general enough to be applicable in a wide | |||
| 22 | 22 | variety of other domains, as well. | |
| 23 | 23 | ||
| 24 | 24 | **If you want to contribute to TensorFlow, be sure to review the [contribution | |
| 25 | - guidelines](CONTRIBUTING.md).** | ||
| 25 | + guidelines](CONTRIBUTING.md). This project adheres to TensorFlow's | ||
| 26 | + [code of conduct](CODE_OF_CONDUCT.md). By participating, you are expected to | ||
| 27 | + uphold this code.** | ||
| 26 | 28 | ||
| 27 | 29 | **We use [GitHub issues](https://github.com/tensorflow/tensorflow/issues) for | |
| 28 | 30 | tracking requests and bugs. So please see | |
@@ -57,7 +59,7 @@ $ python | |||
| 57 | 59 | >>> b = tf.constant(32) | |
| 58 | 60 | >>> sess.run(a + b) | |
| 59 | 61 | 42 | |
| 60 | - >>> | ||
| 62 | + >>> sess.close() | ||
| 61 | 63 | ``` | |
| 62 | 64 | ||
| 63 | 65 | ## For more information | |
@@ -69,3 +71,7 @@ $ python | |||
| 69 | 71 | * [TensorFlow course at Stanford](https://web.stanford.edu/class/cs20si) | |
| 70 | 72 | ||
| 71 | 73 | Learn more about the TensorFlow community at the [community page of tensorflow.org](https://www.tensorflow.org/community) for a few ways to participate. | |
| 74 | + | ||
| 75 | + ## License | ||
| 76 | + | ||
| 77 | + [Apache License 2.0](LICENSE) | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -25,6 +25,11 @@ | |||
| 25 | 25 | import subprocess | |
| 26 | 26 | import sys | |
| 27 | 27 | ||
| 28 | + try: | ||
| 29 | + from shutil import which | ||
| 30 | + except ImportError: | ||
| 31 | + from distutils.spawn import find_executable as which | ||
| 32 | + | ||
| 28 | 33 | _TF_BAZELRC = '.tf_configure.bazelrc' | |
| 29 | 34 | _DEFAULT_CUDA_VERSION = '8.0' | |
| 30 | 35 | _DEFAULT_CUDNN_VERSION = '6' | |
@@ -53,6 +58,10 @@ def is_ppc64le(): | |||
| 53 | 58 | return platform.machine() == 'ppc64le' | |
| 54 | 59 | ||
| 55 | 60 | ||
| 61 | + def is_cygwin(): | ||
| 62 | + return platform.system().startswith('CYGWIN_NT') | ||
| 63 | + | ||
| 64 | + | ||
| 56 | 65 | def get_input(question): | |
| 57 | 66 | try: | |
| 58 | 67 | try: | |
@@ -121,13 +130,20 @@ def write_action_env_to_bazelrc(var_name, var): | |||
| 121 | 130 | write_to_bazelrc('build --action_env %s="%s"' % (var_name, str(var))) | |
| 122 | 131 | ||
| 123 | 132 | ||
| 124 | - def run_shell(cmd): | ||
| 125 | - return subprocess.check_output(cmd, shell=True).decode('UTF-8').strip() | ||
| 133 | + def run_shell(cmd, allow_non_zero=False): | ||
| 134 | + if allow_non_zero: | ||
| 135 | + try: | ||
| 136 | + output = subprocess.check_output(cmd) | ||
| 137 | + except subprocess.CalledProcessError as e: | ||
| 138 | + output = e.output | ||
| 139 | + else: | ||
| 140 | + output = subprocess.check_output(cmd) | ||
| 141 | + return output.decode('UTF-8').strip() | ||
| 126 | 142 | ||
| 127 | 143 | ||
| 128 | 144 | def cygpath(path): | |
| 129 | 145 | """Convert path from posix to windows.""" | |
| 130 | - return run_shell('cygpath -m "%s"' % path) | ||
| 146 | + return run_shell(['cygpath', '-m', path]) | ||
| 131 | 147 | ||
| 132 | 148 | ||
| 133 | 149 | def get_python_path(environ_cp, python_bin_path): | |
@@ -136,20 +152,14 @@ def get_python_path(environ_cp, python_bin_path): | |||
| 136 | 152 | if environ_cp.get('PYTHONPATH'): | |
| 137 | 153 | python_paths = environ_cp.get('PYTHONPATH').split(':') | |
| 138 | 154 | try: | |
| 139 | - check_input = [ | ||
| 140 | - python_bin_path, '-c', | ||
| 141 | - 'import site; print("\\n".join(site.getsitepackages()))' | ||
| 142 | - ] | ||
| 143 | - library_paths = subprocess.check_output(check_input).decode( | ||
| 144 | - 'UTF-8').strip().split('\n') | ||
| 155 | + library_paths = run_shell( | ||
| 156 | + [python_bin_path, '-c', | ||
| 157 | + 'import site; print("\\n".join(site.getsitepackages()))']).split("\n") | ||
| 145 | 158 | except subprocess.CalledProcessError: | |
| 146 | - check_input = [ | ||
| 147 | - python_bin_path, '-c', 'from distutils.sysconfig import get_python_lib;' | ||
| 148 | - + 'print(get_python_lib())' | ||
| 149 | - ] | ||
| 150 | - library_paths = [ | ||
| 151 | - subprocess.check_output(check_input).decode('UTF-8').strip() | ||
| 152 | - ] | ||
| 159 | + library_paths = [run_shell( | ||
| 160 | + [python_bin_path, '-c', | ||
| 161 | + 'from distutils.sysconfig import get_python_lib;' | ||
| 162 | + 'print(get_python_lib())'])] | ||
| 153 | 163 | ||
| 154 | 164 | all_paths = set(python_paths + library_paths) | |
| 155 | 165 | ||
@@ -162,8 +172,7 @@ def get_python_path(environ_cp, python_bin_path): | |||
| 162 | 172 | ||
| 163 | 173 | def get_python_major_version(python_bin_path): | |
| 164 | 174 | """Get the python major version.""" | |
| 165 | - check_input = [python_bin_path, '-c', 'import sys; print(sys.version[0])'] | ||
| 166 | - return subprocess.check_output(check_input).decode('UTF-8').strip() | ||
| 175 | + return run_shell([python_bin_path, '-c', 'import sys; print(sys.version[0])']) | ||
| 167 | 176 | ||
| 168 | 177 | ||
| 169 | 178 | def setup_python(environ_cp, bazel_version): | |
@@ -177,8 +186,8 @@ def setup_python(environ_cp, bazel_version): | |||
| 177 | 186 | environ_cp, 'PYTHON_BIN_PATH', ask_python_bin_path, | |
| 178 | 187 | default_python_bin_path) | |
| 179 | 188 | # Check if the path is valid | |
| 180 | - if (os.path.isfile(python_bin_path) and os.access( | ||
| 181 | - python_bin_path, os.X_OK)) or (os.path.isdir(python_bin_path)): | ||
| 189 | + if os.path.isfile(python_bin_path) and os.access( | ||
| 190 | + python_bin_path, os.X_OK): | ||
| 182 | 191 | break | |
| 183 | 192 | elif not os.path.exists(python_bin_path): | |
| 184 | 193 | print('Invalid python path: %s cannot be found.' % python_bin_path) | |
@@ -187,7 +196,7 @@ def setup_python(environ_cp, bazel_version): | |||
| 187 | 196 | environ_cp['PYTHON_BIN_PATH'] = '' | |
| 188 | 197 | ||
| 189 | 198 | # Convert python path to Windows style before checking lib and version | |
| 190 | - if is_windows(): | ||
| 199 | + if is_cygwin(): | ||
| 191 | 200 | python_bin_path = cygpath(python_bin_path) | |
| 192 | 201 | ||
| 193 | 202 | # Get PYTHON_LIB_PATH | |
@@ -197,20 +206,20 @@ def setup_python(environ_cp, bazel_version): | |||
| 197 | 206 | if environ_cp.get('USE_DEFAULT_PYTHON_LIB_PATH') == '1': | |
| 198 | 207 | python_lib_path = python_lib_paths[0] | |
| 199 | 208 | else: | |
| 200 | - print('Found possible Python library paths:\n%s' % | ||
| 201 | - '\n'.join(python_lib_paths)) | ||
| 209 | + print('Found possible Python library paths:\n %s' % | ||
| 210 | + '\n '.join(python_lib_paths)) | ||
| 202 | 211 | default_python_lib_path = python_lib_paths[0] | |
| 203 | 212 | python_lib_path = get_input( | |
| 204 | - 'Please input the desired Python library path to use. Default is %s' | ||
| 205 | - % python_lib_paths[0]) | ||
| 213 | + 'Please input the desired Python library path to use. ' | ||
| 214 | + 'Default is [%s]\n' % python_lib_paths[0]) | ||
| 206 | 215 | if not python_lib_path: | |
| 207 | 216 | python_lib_path = default_python_lib_path | |
| 208 | 217 | environ_cp['PYTHON_LIB_PATH'] = python_lib_path | |
| 209 | 218 | ||
| 210 | 219 | python_major_version = get_python_major_version(python_bin_path) | |
| 211 | 220 | ||
| 212 | 221 | # Convert python path to Windows style before writing into bazel.rc | |
| 213 | - if is_windows(): | ||
| 222 | + if is_cygwin(): | ||
| 214 | 223 | python_lib_path = cygpath(python_lib_path) | |
| 215 | 224 | ||
| 216 | 225 | # Set-up env variables used by python_configure.bzl | |
@@ -432,11 +441,10 @@ def check_bazel_version(min_version): | |||
| 432 | 441 | Returns: | |
| 433 | 442 | The bazel version detected. | |
| 434 | 443 | """ | |
| 435 | - try: | ||
| 436 | - curr_version = run_shell('bazel --batch version') | ||
| 437 | - except subprocess.CalledProcessError: | ||
| 444 | + if which('bazel') is None: | ||
| 438 | 445 | print('Cannot find bazel. Please install bazel.') | |
| 439 | 446 | sys.exit(0) | |
| 447 | + curr_version = run_shell(['bazel', '--batch', 'version']) | ||
| 440 | 448 | ||
| 441 | 449 | for line in curr_version.split('\n'): | |
| 442 | 450 | if 'Build label: ' in line: | |
@@ -529,7 +537,7 @@ def get_from_env_or_user_or_default(environ_cp, var_name, ask_for_var, | |||
| 529 | 537 | ||
| 530 | 538 | def set_clang_cuda_compiler_path(environ_cp): | |
| 531 | 539 | """Set CLANG_CUDA_COMPILER_PATH.""" | |
| 532 | - default_clang_path = run_shell('which clang || true') | ||
| 540 | + default_clang_path = which('clang') or '' | ||
| 533 | 541 | ask_clang_path = ('Please specify which clang should be used as device and ' | |
| 534 | 542 | 'host compiler. [Default is %s]: ') % default_clang_path | |
| 535 | 543 | ||
@@ -552,12 +560,12 @@ def set_clang_cuda_compiler_path(environ_cp): | |||
| 552 | 560 | ||
| 553 | 561 | def set_gcc_host_compiler_path(environ_cp): | |
| 554 | 562 | """Set GCC_HOST_COMPILER_PATH.""" | |
| 555 | - default_gcc_host_compiler_path = run_shell('which gcc || true') | ||
| 563 | + default_gcc_host_compiler_path = which('gcc') or '' | ||
| 556 | 564 | cuda_bin_symlink = '%s/bin/gcc' % environ_cp.get('CUDA_TOOLKIT_PATH') | |
| 557 | 565 | ||
| 558 | 566 | if os.path.islink(cuda_bin_symlink): | |
| 559 | 567 | # os.readlink is only available in linux | |
| 560 | - default_gcc_host_compiler_path = run_shell('readlink %s' % cuda_bin_symlink) | ||
| 568 | + default_gcc_host_compiler_path = os.path.realpath(cuda_bin_symlink) | ||
| 561 | 569 | ||
| 562 | 570 | ask_gcc_path = ( | |
| 563 | 571 | 'Please specify which gcc should be used by nvcc as the ' | |
@@ -592,7 +600,7 @@ def set_tf_cuda_version(environ_cp): | |||
| 592 | 600 | ||
| 593 | 601 | # Find out where the CUDA toolkit is installed | |
| 594 | 602 | default_cuda_path = _DEFAULT_CUDA_PATH | |
| 595 | - if is_windows(): | ||
| 603 | + if is_cygwin(): | ||
| 596 | 604 | default_cuda_path = cygpath( | |
| 597 | 605 | environ_cp.get('CUDA_PATH', _DEFAULT_CUDA_PATH_WIN)) | |
| 598 | 606 | elif is_linux(): | |
@@ -633,7 +641,7 @@ def set_tf_cuda_version(environ_cp): | |||
| 633 | 641 | def set_tf_cunn_version(environ_cp): | |
| 634 | 642 | """Set CUDNN_INSTALL_PATH and TF_CUDNN_VERSION.""" | |
| 635 | 643 | ask_cudnn_version = ( | |
| 636 | - '"Please specify the cuDNN version you want to use. ' | ||
| 644 | + 'Please specify the cuDNN version you want to use. ' | ||
| 637 | 645 | '[Leave empty to default to cuDNN %s.0]: ') % _DEFAULT_CUDNN_VERSION | |
| 638 | 646 | ||
| 639 | 647 | while True: | |
@@ -652,7 +660,7 @@ def set_tf_cunn_version(environ_cp): | |||
| 652 | 660 | # unusable. Going through one more level of expansion to handle that. | |
| 653 | 661 | cudnn_install_path = os.path.realpath( | |
| 654 | 662 | os.path.expanduser(cudnn_install_path)) | |
| 655 | - if is_windows(): | ||
| 663 | + if is_cygwin(): | ||
| 656 | 664 | cudnn_install_path = cygpath(cudnn_install_path) | |
| 657 | 665 | ||
| 658 | 666 | if is_windows(): | |
@@ -674,12 +682,10 @@ def set_tf_cunn_version(environ_cp): | |||
| 674 | 682 | ||
| 675 | 683 | # Try another alternative for Linux | |
| 676 | 684 | if is_linux(): | |
| 677 | - if subprocess.call(['which', 'ldconfig']): | ||
| 678 | - ldconfig_bin = '/sbin/ldconfig' | ||
| 679 | - else: | ||
| 680 | - ldconfig_bin = 'ldconfig' | ||
| 681 | - cudnn_path_from_ldconfig = run_shell( | ||
| 682 | - r'%s -p | sed -n "s/.*libcudnn.so .* => \(.*\)/\\1/p"' % ldconfig_bin) | ||
| 685 | + ldconfig_bin = which('ldconfig') or '/sbin/ldconfig' | ||
| 686 | + cudnn_path_from_ldconfig = run_shell([ldconfig_bin, '-p']) | ||
| 687 | + cudnn_path_from_ldconfig = re.search('.*libcudnn.so .* => (.*)', | ||
| 688 | + cudnn_path_from_ldconfig).group(1) | ||
| 683 | 689 | if os.path.exists('%s.%s' % (cudnn_path_from_ldconfig, tf_cudnn_version)): | |
| 684 | 690 | cudnn_install_path = os.path.dirname(cudnn_path_from_ldconfig) | |
| 685 | 691 | break | |
@@ -712,11 +718,15 @@ def get_native_cuda_compute_capabilities(environ_cp): | |||
| 712 | 718 | """ | |
| 713 | 719 | device_query_bin = os.path.join( | |
| 714 | 720 | environ_cp.get('CUDA_TOOLKIT_PATH'), 'extras/demo_suite/deviceQuery') | |
| 715 | - cmd = (r'"%s" | grep "Capability" | grep -o "[0-9]*\.[0-9]*" | sed ' | ||
| 716 | - '":a;{N;s/\\n/,/};ba"') % device_query_bin | ||
| 717 | - try: | ||
| 718 | - output = run_shell(cmd) | ||
| 719 | - except subprocess.CalledProcessError: | ||
| 721 | + if os.path.isfile(device_query_bin) and os.access(device_query_bin, os.X_OK): | ||
| 722 | + try: | ||
| 723 | + output = run_shell(device_query_bin).split('\n') | ||
| 724 | + pattern = re.compile('[0-9]*\\.[0-9]*') | ||
| 725 | + output = [pattern.search(x) for x in output if 'Capability' in x] | ||
| 726 | + output = ','.join(x.group() for x in output if x is not None) | ||
| 727 | + except subprocess.CalledProcessError: | ||
| 728 | + output = '' | ||
| 729 | + else: | ||
| 720 | 730 | output = '' | |
| 721 | 731 | return output | |
| 722 | 732 | ||
@@ -797,7 +807,7 @@ def set_other_cuda_vars(environ_cp): | |||
| 797 | 807 | ||
| 798 | 808 | def set_host_cxx_compiler(environ_cp): | |
| 799 | 809 | """Set HOST_CXX_COMPILER.""" | |
| 800 | - default_cxx_host_compiler = run_shell('which g++ || true') | ||
| 810 | + default_cxx_host_compiler = which('g++') or '' | ||
| 801 | 811 | ask_cxx_host_compiler = ( | |
| 802 | 812 | 'Please specify which C++ compiler should be used as' | |
| 803 | 813 | ' the host C++ compiler. [Default is %s]: ') % default_cxx_host_compiler | |
@@ -820,7 +830,7 @@ def set_host_cxx_compiler(environ_cp): | |||
| 820 | 830 | ||
| 821 | 831 | def set_host_c_compiler(environ_cp): | |
| 822 | 832 | """Set HOST_C_COMPILER.""" | |
| 823 | - default_c_host_compiler = run_shell('which gcc || true') | ||
| 833 | + default_c_host_compiler = which('gcc') or '' | ||
| 824 | 834 | ask_c_host_compiler = ( | |
| 825 | 835 | 'Please specify which C compiler should be used as the' | |
| 826 | 836 | ' host C compiler. [Default is %s]: ') % default_c_host_compiler | |
@@ -874,9 +884,9 @@ def set_computecpp_toolkit_path(environ_cp): | |||
| 874 | 884 | ||
| 875 | 885 | def set_mpi_home(environ_cp): | |
| 876 | 886 | """Set MPI_HOME.""" | |
| 877 | - cmd = ('dirname $(dirname $(which mpirun)) || dirname $(dirname $(which ' | ||
| 878 | - 'mpiexec)) || true') | ||
| 879 | - default_mpi_home = run_shell(cmd) | ||
| 887 | + default_mpi_home = which('mpirun') or which('mpiexec') or '' | ||
| 888 | + default_mpi_home = os.path.dirname(os.path.dirname(default_mpi_home)) | ||
| 889 | + | ||
| 880 | 890 | ask_mpi_home = ('Please specify the MPI toolkit folder. [Default is %s]: ' | |
| 881 | 891 | ) % default_mpi_home | |
| 882 | 892 | while True: | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -465,6 +465,7 @@ cc_binary( | |||
| 465 | 465 | "//tensorflow/c:c_api", | |
| 466 | 466 | "//tensorflow/c:exported_symbols.lds", | |
| 467 | 467 | "//tensorflow/c:version_script.lds", | |
| 468 | + "//tensorflow/c/eager:c_api", | ||
| 468 | 469 | "//tensorflow/core:tensorflow", | |
| 469 | 470 | ], | |
| 470 | 471 | ) | |
@@ -474,6 +475,7 @@ cc_binary( | |||
| 474 | 475 | linkshared = 1, | |
| 475 | 476 | deps = [ | |
| 476 | 477 | "//tensorflow/c:c_api", | |
| 478 | + "//tensorflow/c/eager:c_api", | ||
| 477 | 479 | "//tensorflow/cc:cc_ops", | |
| 478 | 480 | "//tensorflow/cc:client_session", | |
| 479 | 481 | "//tensorflow/cc:scope", | |
| Back | FazBrowse Home | New Git URL |
0 commit comments