Tensorflow operations are unsusably slow

你离开我真会死。 提交于 2021-02-19 03:48:46

问题


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:

来源:https://stackoverflow.com/questions/55335828/tensorflow-operations-are-unsusably-slow

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!