使用tensorflow c ++ api时,特定的gpu设备失败

时间:2017-02-26 16:39:19

标签: python c++ tensorflow gpu

我在python中训练了我的tf模型:

  with sv.managed_session(master='') as sess:
    with tf.device("/gpu:1"):#my systerm has 4 nvidia cards

并使用命令行抽象模型:

  freeze_graph.py --clear_devices False

在测试阶段,我将设备设置如下:

  tensorflow::graph::SetDefaultDevice("/gpu:1", &tensorflow_graph);

但有些不对劲:

  ould not create Tensorflow Graph: 
  Invalid argument: Cannot assign a device to node '.../RNN_backword/while/Enter': 
  Could not satisfy explicit device specification '/gpu:1' 
  because no devices matching that specification are registered in this process; 
  available devices: /job:localhost/replica:0/task:0/cpu:0

那么,我怎样才能正确使用gpu?

谁能帮忙?

1 个答案:

答案 0 :(得分:0)

您是否可以使用未启用GPU支持的TensorFlow版本?如果您正在构建二进制文件,则可能需要从// tensorflow添加启用GPU支持的其他BUILD规则。还要确保在运行configure时启用了GPU支持。

编辑:你能否在TF的github问题上提出错误:

1)你的BUILD规则

2)更多代码,以便我们了解您如何构建模型并创建会话

3)你如何运行configure

虽然此API尚未标记为“公开”;我们想看看你是否确实遇到了一个错误,所以我们可以修复它。