我正在尝试使用JIT编译运行一个简单的tensorflow示例,如https://www.tensorflow.org/versions/master/experimental/xla/jit所示。我不使用mnist_softmax_xla示例,而是使用以下代码:
def main(_):
config = tf.ConfigProto(log_device_placement=True)
jit_level = 0
if FLAGS.xla:
# Turns on XLA JIT compilation.
jit_level = tf.OptimizerOptions.ON_1
config.graph_options.optimizer_options.global_jit_level = jit_level
# Creates a session with log_device_placement set to True.
with tf.Session(config=config) as sess:
# Creates a graph.
with tf.device('/job:localhost/replica:0/task:0/device:XLA_CPU:0'):
a = tf.constant([1.0, 2.0, 3.0, 4.0, 5.0, 6.0], shape=[2, 3], name='a')
b = tf.constant([1.0, 2.0, 3.0, 4.0, 5.0, 6.0], shape=[3, 2], name='b')
c = tf.matmul(a, b)
# Runs the op.
print(sess.run(c))我收到一个错误:
tensorflow.python.framework.errors_impl.InvalidArgumentError: Cannot assign a device to node 'MatMul': Could not satisfy explicit device specification '/job:localhost/replica:0/task:0/device:XLA_CPU:0' because no devices matching that specification are registered in this process; available devices: /job:localhost/replica:0/task:0/cpu:0
[[Node: MatMul = MatMul[T=DT_FLOAT, transpose_a=false, transpose_b=false, _device="/job:localhost/replica:0/task:0/device:XLA_CPU:0"](a, b)]]我做错了什么?
发布于 2017-03-11 05:26:35
原来我是和Python2一起跑的。它现在可以在Python3下运行
https://stackoverflow.com/questions/42541323
复制相似问题