如何解决AI Platform 训练比本地慢
我正在使用 AI 平台训练 LSTM 模型,如下所示:
我的 config.yaml 文件:
trainingInput:
runtimeVersion: "2.2"
pythonVersion: "3.7"
scaleTier: CUSTOM
masterType: n1-standard-16
workerType: n1-standard-16
workerCount: 2
scheduling:
maxWaitTime: 3600s
maxRunningTime: 7200s
训练代码:
strategy = tf.distribute.experimental.MultiWorkerMirroredStrategy()
with strategy.scope():
keras_model = model.create_model(args.learning_rate)
history = (keras_model.fit(
x_train,y_train,epochs=args.num_epochs,steps_per_epoch = steps_per_epoch,verbose = 1,validation_data = (x_val,y_val),validation_steps=validation_steps))
运行作业:
cloud ai-platform jobs submit training $JOB_NAME --region $REGION --package-path trainer --module-name trainer.task --config config.yaml --job-dir $JOB_DIR
但是,在本地运行作业时,它的训练速度要快得多,每个 epoch 在 2 分钟内完成,而在 AI 平台上大约需要 5 分钟或更长时间。
我正在做的事情一定有严重错误,但我没有想法,任何帮助表示赞赏。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。