Tensorflow操作非常缓慢

时间:2019-03-25 10:33:24

标签: python performance tensorflow

我正在尝试使用python接口使用tensorflow。我的问题是,即使执行最基本的操作,它们也要花费很长时间(> 5分钟)

当使用从Macports和tensorflow-1.13,tf-nightly和tensorflow2.0 alpha安装的python3.6都使用pip安装时会发生此问题。

这个简单的示例需要超过5分钟的时间来执行。

> 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)

一段时间后,我中断了执行,回溯如下。有人有建议吗?

KeyboardInterrupt

回溯(最近通话最近)  在

----> 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 constant_v1(值,dtype,形状,名称,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 _constant_impl(值,dtype,形状,名称,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在 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在 create_op( 解析参数失败

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在   init (自身,node_def,g,输入,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在 _create_c_op(图形,node_def,输入,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:

0 个答案:

没有答案