diff options
author | Jonathan Hseu <jhseu@google.com> | 2017-02-28 18:36:23 -0800 |
---|---|---|
committer | TensorFlower Gardener <gardener@tensorflow.org> | 2017-02-28 18:51:06 -0800 |
commit | 718812c9e4df55b8b3275aa4db7bb6833ed03111 (patch) | |
tree | e8bc57fe5bfaea125d4d4c4535e29a7ed2306057 /tensorflow/python/__init__.py | |
parent | 4e63540076921d2c08d03aa9efb76fd483920593 (diff) |
Fix the dlopen contrib test hack by making a pywrap_tensorflow module that imports
pywrap_tensorflow_internal with RTLD_GLOBAL.
Fixes #6568
Change: 148843302
Diffstat (limited to 'tensorflow/python/__init__.py')
-rw-r--r-- | tensorflow/python/__init__.py | 25 |
1 files changed, 2 insertions, 23 deletions
diff --git a/tensorflow/python/__init__.py b/tensorflow/python/__init__.py index 917c2fb991..96281f5192 100644 --- a/tensorflow/python/__init__.py +++ b/tensorflow/python/__init__.py @@ -46,30 +46,9 @@ import traceback # go/tf-wildcard-import # pylint: disable=wildcard-import,g-bad-import-order,g-import-not-at-top -# On UNIX-based platforms, pywrap_tensorflow is a SWIG-generated -# python library that dynamically loads _pywrap_tensorflow.so. The -# default mode for loading keeps all the symbol private and not -# visible to other libraries that may be loaded. Setting the mode to -# RTLD_GLOBAL to make the symbols visible, so that custom op libraries -# imported using `tf.load_op_library()` can access symbols defined in -# _pywrap_tensorflow.so. import numpy as np -try: - if hasattr(sys, 'getdlopenflags') and hasattr(sys, 'setdlopenflags'): - _default_dlopen_flags = sys.getdlopenflags() - sys.setdlopenflags(_default_dlopen_flags | ctypes.RTLD_GLOBAL) - from tensorflow.python import pywrap_tensorflow - sys.setdlopenflags(_default_dlopen_flags) - else: - # TODO(keveman,mrry): Support dynamic op loading on platforms that do not - # use `dlopen()` for dynamic loading. - from tensorflow.python import pywrap_tensorflow -except ImportError: - msg = """%s\n\nFailed to load the native TensorFlow runtime.\n -See https://github.com/tensorflow/tensorflow/blob/master/tensorflow/g3doc/get_started/os_setup.md#import_error\n -for some common reasons and solutions. Include the entire stack trace -above this error message when asking for help.""" % traceback.format_exc() - raise ImportError(msg) + +from tensorflow.python import pywrap_tensorflow # Protocol buffers from tensorflow.core.framework.graph_pb2 import * |