运行 google 云 ML 上分布式模式下的 tensorflow 代码

Run a tensorflow code in distributed mode on google cloud ML

有人知道需要对培训师进行哪些更改才能 运行 在 google 云 ML 的分布式平台上工作吗?

如果有人能分享几篇相同的文章或文档,那将会很有帮助。

Run Distributed Training in the Cloud 中的参数 "scale-tier" 是否回答了您的问题?

gcloud ml-engine jobs submit training $JOB_NAME \
   --job-dir $OUTPUT_PATH \
   --runtime-version 1.0 \
   --module-name trainer.task \
   --package-path trainer/ \
   --region $REGION \
   --scale-tier STANDARD_1 \
   -- \
   --train-files $TRAIN_DATA \
   --eval-files $EVAL_DATA \
   --train-steps 1000 \
   --verbose-logging true

总的来说,您的分布式 TensorFlow 程序将完全是分布式 TensorFlow,只有极少甚至没有特定于云的更改。分布式 TensorFlow 的最佳资源是 tensorflow.org 上的 this tutorial。本教程将引导您完成低级别的处理方式。

还有一个更高级别的 API,目前在 contrib 中(因此 API 可能会更改,并将在未来的版本中移出 contrib),它简化了样板代码的数量必须为分布式训练而写。官方教程是here.

一旦您理解了一般的 TensorFlow 位(无论是高级还是低级 APIs),您的代码中必须存在一些特定元素才能使其达到 运行 在 CloudML 引擎上。对于低级 TensorFlow APIs,您需要解析 TF_CONFIG 环境变量来设置您的 ClusterSpec。这在 this example (see specifically this 代码块中得到了例证。

更高级别 API 的一个优点是,所有这些解析都已经为您处理好了。您的代码通常应该可以正常工作。请参阅 this example. The important piece is that you will need to use learn_runner.run() (see this 行),它将在本地和云端工作以训练您的模型。

当然还有其他的框架,比如TensorFX.

适当地构建代码后,您只需select一个适当的scale tier that has multiple machines when launching your training job. (See 示例答案)

希望对您有所帮助!

如果您的模型是使用 Tensorflow Estimator 构建的,那么您需要做的更改非常少。您基本上可以将代码插入例如this boilerplate code.