Google Cloud ML在培训时以非零状态退出245

时间:2017-04-27 07:30:23

标签: machine-learning tensorflow google-cloud-platform google-cloud-ml google-cloud-ml-engine

我尝试使用以下示例代码在Google Cloud ML上训练我的模型:

import keras
from keras import optimizers
from keras import losses
from keras import metrics
from keras.models import Model, Sequential
from keras.layers import Dense, Lambda, RepeatVector, TimeDistributed
import numpy as np

def test():
    model = Sequential()
    model.add(Dense(2, input_shape=(3,)))
    model.add(RepeatVector(3))
    model.add(TimeDistributed(Dense(3)))
    model.compile(loss=losses.MSE,
                  optimizer=optimizers.RMSprop(lr=0.0001),
                  metrics=[metrics.categorical_accuracy],
                  sample_weight_mode='temporal')
    x = np.random.random((1, 3))
    y = np.random.random((1, 3, 3))
    model.train_on_batch(x, y)

if __name__ == '__main__':
    test()

我收到了这个错误:

The replica master 0 exited with a non-zero status of 245. Termination reason: Error.

详细的错误输出很大,所以我粘贴它here in pastebin

2 个答案:

答案 0 :(得分:0)

请注意此输出:

Module raised an exception for failing to call a subprocess Command '['python', '-m', u'trainer.test', '--job-dir', u'gs://my_test_bucket_keras/s_27_100630']' returned non-zero exit status -11.

我想谷歌云将使用名为--job-dir的额外参数运行您的代码。那么也许您可以尝试在示例代码中添加以下代码?

import ...
import argparse

def test():
model = Sequential()
model.add(Dense(2, input_shape=(3,)))
model.add(RepeatVector(3))
model.add(TimeDistributed(Dense(3)))
model.compile(loss=losses.MSE,
              optimizer=optimizers.RMSprop(lr=0.0001),
              metrics=[metrics.categorical_accuracy],
              sample_weight_mode='temporal')
x = np.random.random((1, 3))
y = np.random.random((1, 3, 3))
model.train_on_batch(x, y)

if __name__ == '__main__':
    parser = argparse.ArgumentParser()
    # Input Arguments
    parser.add_argument(
      '--job-dir',
      help='GCS location to write checkpoints and export models',
      required=True
    )
    args = parser.parse_args()
    arguments = args.__dict__

    test()
    # test(**arguments) # or if you want to use this job_dir parameter in your code

不是100%确定这会有效,但我认为你可以尝试一下。 我也有post here做类似的事情,也许你也可以看看那里。

答案 1 :(得分:0)

问题已解决。我所要做的就是使用tensorflow 1.1.0而不是默认的1.0.1