3

I'm trying to get started with tensorflow using the python interface. My problem is that executing even the most basic operations, they take a long time (> 5 minutes)

This problem occurs when using python3.6, installed from macports and tensorflow-1.13, the tf-nightly, and tensorflow2.0 alpha, all installed using pip.

This simple example takes more than 5 minutes to execute.

> ipython
Python 3.6.8 (default, Dec 30 2018, 13:01:27) 
In [1]: import numpy as np 
In [2]: import tensorflow as tf
In [3]: print(tf.__version__)
1.13.1
In [4]: a = tf.constant(4.0, dtype=tf.float32)

After some time, I interrupted the execution, the traceback is below. Does anyone have a suggestion?

KeyboardInterrupt

Traceback (most recent call last) in

----> 1 a = tf.constant(4.0, dtype=tf.float32)

/opt/local/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/tensorflow/python/framework/constant_op.py in constant_v1(value, dtype, shape, name, verify_shape)

177   """
178   return _constant_impl(value, dtype, shape, name, verify_shape=verify_shape,
--> 179                         allow_broadcast=False)
180 
181 

/opt/local/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/tensorflow/python/framework/constant_op.py in _constant_impl(value, dtype, shape, name, verify_shape, allow_broadcast)

287       attrs={"value": tensor_value,
288              "dtype": dtype_value},
--> 289       name=name).outputs[0]
290   return const_tensor
291 

/opt/local/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/tensorflow/python/util/deprecation.py in new_func(*args, **kwargs)

505                 'in a future version' if date is None else ('after %s' % date),
506                 instructions)
--> 507       return func(*args, **kwargs)
508 
509     doc = _add_deprecated_arg_notice_to_docstring(

/opt/local/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/tensorflow/python/framework/ops.py in create_op(failed resolving arguments)

3298           input_types=input_types,

3299           original_op=self._default_original_op,

-> 3300           op_def=op_def)
3301       self._create_op_helper(ret, compute_device=compute_device)
3302     return ret

/opt/local/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/tensorflow/python/framework/ops.py in init(self, node_def, g, inputs, output_types, control_inputs, input_types, original_op, op_def)

1821           op_def, inputs, node_def.attr)
1822       self._c_op = _create_c_op(self._graph, node_def, grouped_inputs,
-> 1823                                 control_input_ops)
1824 
1825     # Initialize self._outputs.

/opt/local/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/tensorflow/python/framework/ops.py in _create_c_op(graph, node_def, inputs, control_inputs)

1654     # TODO(skyewm): this creates and deletes a new TF_Status for every attr.
1655     # It might be worth creating a convenient way to re-use the same status.
-> 1656     c_api.TF_SetAttrValueProto(op_desc, compat.as_str(name), serialized)
1657 
1658   try:

KeyboardInterrupt:

Ralph Kube
  • 53
  • 4
  • This is rather curious. Does the computation run on CPU or GPU? – MPA Mar 25 '19 at 11:14
  • are you running tensorflow or tensorflow-gpu ? – Vaibhav gusain Mar 25 '19 at 12:09
  • 1
    I have exactly the same issue. Updated keras, tensorflow, etc. yesterday from macports. In my case it hung when creating an Input() layer. The trace ends in exactly the same place (exactly the same line in c_api). top shows that python is using 100% of one cpu core and memory usage is constantly increasing (after 2.5 minutes it's more than 750MB). – Johan Mar 28 '19 at 19:19

0 Answers0