You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Have I written custom code (as opposed to using a stock example script provided in TensorFlow):
Yes
OS Platform and Distribution (e.g., Linux Ubuntu 16.04):
Mac OS X 10.13.6
Mobile device (e.g. iPhone 8, Pixel 2, Samsung Galaxy) if the issue happens on mobile device:
N/A
TensorFlow installed from (source or binary):
binary
TensorFlow version (use command below):
VERSION="1.13.0-dev20181226" (this is the TF 2.0-preview)
GIT_VERSION="b'v1.12.0-5133-gc343196842'"
Python version:
3.6.6
Bazel version (if compiling from source):
N/A
GCC/Compiler version (if compiling from source):
N/A
CUDA/cuDNN version:
N/A
GPU model and memory:
N/A
Describe the current behavior tf.function raises an OSError exception with the message "could not get source code" when I run it in a Python shell. The error does not occur in Jupyter or ipython, and it does not occur when I revert back to TF 1.12.0.
Here is the output of the above commands when I run them in a Python shell:
(tf2) $ python
Python 3.6.6 (default, Jun 28 2018, 05:43:53)
[GCC 4.2.1 Compatible Apple LLVM 9.1.0 (clang-902.0.39.2)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import tensorflow as tf
>>> @tf.function
... deffoo():
... return42
...
>>> foo()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Users/ageron/.virtualenvs/tf2/lib/python3.6/site-packages/tensorflow/python/eager/def_function.py", line 336, in __call__
self._initialize(args, kwds)
File "/Users/ageron/.virtualenvs/tf2/lib/python3.6/site-packages/tensorflow/python/eager/def_function.py", line 309, in _initialize
*args, **kwds))
File "/Users/ageron/.virtualenvs/tf2/lib/python3.6/site-packages/tensorflow/python/eager/function.py", line 1024, in _get_concrete_function_internal_garbage_collected
graph_function, _, _ = self._maybe_define_function(args, kwargs)
File "/Users/ageron/.virtualenvs/tf2/lib/python3.6/site-packages/tensorflow/python/eager/function.py", line 1247, in _maybe_define_function
arg_names=arg_names),
File "/Users/ageron/.virtualenvs/tf2/lib/python3.6/site-packages/tensorflow/python/framework/func_graph.py", line 456, in func_graph_from_py_func
func_outputs = python_func(*func_args, **func_kwargs)
File "/Users/ageron/.virtualenvs/tf2/lib/python3.6/site-packages/tensorflow/python/eager/def_function.py", line 261, in wrapped_fn
return weak_wrapped_fn().__wrapped__(*args, **kwds)
File "/Users/ageron/.virtualenvs/tf2/lib/python3.6/site-packages/tensorflow/python/framework/func_graph.py", line 449, in wrapper
), *args, **kwargs)
File "/Users/ageron/.virtualenvs/tf2/lib/python3.6/site-packages/tensorflow/python/autograph/impl/api.py", line 293, in converted_call
experimental_partial_types=partial_types)
File "/Users/ageron/.virtualenvs/tf2/lib/python3.6/site-packages/tensorflow/python/autograph/impl/api.py", line 415, in to_graph
arg_values, arg_types)
File "/Users/ageron/.virtualenvs/tf2/lib/python3.6/site-packages/tensorflow/python/autograph/impl/conversion.py", line 175, in entity_to_graph
node, name, ns = function_to_graph(o, program_ctx, arg_values, arg_types)
File "/Users/ageron/.virtualenvs/tf2/lib/python3.6/site-packages/tensorflow/python/autograph/impl/conversion.py", line 338, in function_to_graph
node, source = parser.parse_entity(f)
File "/Users/ageron/.virtualenvs/tf2/lib/python3.6/site-packages/tensorflow/python/autograph/pyct/parser.py", line 34, in parse_entity
source = tf_inspect.getsource(entity)
File "/Users/ageron/.virtualenvs/tf2/lib/python3.6/site-packages/tensorflow/python/util/tf_inspect.py", line 327, in getsource
return _inspect.getsource(tf_decorator.unwrap(object)[1])
File "/opt/local/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/inspect.py", line 968, in getsource
lines, lnum = getsourcelines(object)
File "/opt/local/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/inspect.py", line 955, in getsourcelines
lines, lnum = findsource(object)
File "/opt/local/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/inspect.py", line 786, in findsource
raise OSError('could not get source code')
OSError: could not get source code
Below is the output when I run the exact same commands in an ipython shell (within the same virtualenv):
(tf2) $ ipython
Python 3.6.6 (default, Jun 28 2018, 05:43:53)
Type 'copyright', 'credits' or 'license' for more information
IPython 7.2.0 -- An enhanced Interactive Python. Type '?' for help.
In [1]: import tensorflow as tf
In [2]: @tf.function
...: def foo():
...: return 42
...:
In [3]: foo()
2019-01-08 13:02:33.785802: I tensorflow/core/platform/cpu_feature_guard.cc:141] Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX2 FMA
Out[3]: <tf.Tensor: id=5, shape=(), dtype=int32, numpy=42>
The result is also good in Jupyter (within the same virtualenv).
This is the output when I switch to another virtualenv based on TF 1.12.0:
(tf1) $ python
Python 3.6.6 (default, Jun 28 2018, 05:43:53)
[GCC 4.2.1 Compatible Apple LLVM 9.1.0 (clang-902.0.39.2)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import tensorflow as tf
>>> tf.enable_eager_execution()
>>> @tf.contrib.eager.defun
... deffoo():
... return42
...
>>> foo()
2019-01-08 12:55:53.087099: I tensorflow/core/platform/cpu_feature_guard.cc:141] Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX2 FMA
<tf.Tensor: id=5, shape=(), dtype=int32, numpy=42>
The text was updated successfully, but these errors were encountered:
Thanks for your feedback @mdanatg. Indeed, until a fix is found, I like the idea of reverting to autograph=False and outputting a warning. Or perhaps simply having a more explicit error message?
System information
Yes
Mac OS X 10.13.6
N/A
binary
VERSION="1.13.0-dev20181226" (this is the TF 2.0-preview)
GIT_VERSION="b'v1.12.0-5133-gc343196842'"
3.6.6
N/A
N/A
N/A
N/A
Describe the current behavior
tf.function
raises anOSError
exception with the message"could not get source code"
when I run it in a Python shell. The error does not occur in Jupyter or ipython, and it does not occur when I revert back to TF 1.12.0.Describe the expected behavior
I expect no error.
Code to reproduce the issue
Other info / logs
Here is the output of the above commands when I run them in a Python shell:
Below is the output when I run the exact same commands in an ipython shell (within the same virtualenv):
The result is also good in Jupyter (within the same virtualenv).
This is the output when I switch to another virtualenv based on TF 1.12.0:
The text was updated successfully, but these errors were encountered: