1

为了使用 contrib.learn.Estimator 进行多 GPU 训练,我试图在我的 model_fn 中指定 GPU 分配。

在伪代码中:

def model_fn(X, y):
    with tf.device('/gpu:1'):
       ... various tensorflow ops for model ...

       return predictions, loss, train_op

没有 tf.device('/gpu:1') 调用一切正常,但使用它我遇到以下错误:

InvalidArgumentError (see above for traceback): Cannot assign a device to
node 'save/ShardedFilename_1': Could not satisfy explicit device
specification '/device:GPU:1' because no supported kernel 
for GPU devices is available.

我不相信我自己将违规操作添加到图表中,而是通过 Estimator 的快照功能注入。

我相信解决方案是设置 allow_soft_placement=True 以便非 GPU 功能将落入 CPU,但在处理 contrib.learn.Estimator 时如何暴露对我来说并不明显。

我看到该选项通常在 ConfigProto 中设置并传递给会话,但我一直在使用 Estimator 的功能为我管理会话。我应该控制会话创建,还是我在某处缺少参数来完成此操作?

非常感谢您的任何建议。

4

1 回答 1

0

随着 Estimator 在 Tensorflow 1.0 中离开 contrib,这是固定的。

于 2017-04-30T21:10:48.780 回答