首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >使用XLA运行Tensorflow时出错

使用XLA运行Tensorflow时出错
EN

Stack Overflow用户
提问于 2017-03-02 04:22:14
回答 1查看 686关注 0票数 0

我正在尝试使用JIT编译运行一个简单的tensorflow示例,如https://www.tensorflow.org/versions/master/experimental/xla/jit所示。我不使用mnist_softmax_xla示例,而是使用以下代码:

代码语言:javascript
复制
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))

我收到一个错误:

代码语言:javascript
复制
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)]]

我做错了什么?

EN

回答 1

Stack Overflow用户

发布于 2017-03-11 05:26:35

原来我是和Python2一起跑的。它现在可以在Python3下运行

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/42541323

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档