也许我的问题有点天真,但我在tensorflow文档中找不到任何东西。Tensorflow,在特定设备中恢复变量
我有一个训练过的tensorflow模型,其中的变量放在GPU中。现在我想恢复这个模型并使用CPU进行测试。
如果我这样做,通过“tf.train.Saver.restore`作为例子: saver = tf.train.import_meta_graph("/tmp/graph.meta") saver.restore(session, "/tmp/model.ckp")
我有以下错误时抛出:
InvalidArgumentError: Cannot assign a device to node 'b_fc8/b_fc8/Adam_1': Could not satisfy explicit device specification '/device:GPU:0' because no devices matching that specification are registered in this process; available devices: /job:localhost/replica:0/task:0/cpu:0
我怎样才能让这些恢复CPU
中的变量?
感谢
感谢DEVICE_COUNT, 其实这个资源是可用的版本'0.11'。 我使用0.10。 –
@TiagoFreitasPereira,然后你可以加载GraphDef,遍历节点,清除字段“设备”,然后将这个GraphDef导入到你的图中 –
也可以在文本编辑器中打开'graph.pbtxt',并删除每一行以'设备:' –