liveBook · Manning

Tf.distribute

As explained in Distributed Machine Learning Patterns

tf.distribute is TensorFlow's API module for distributing computation and model training across devices and workers.

tf.distribute extends local TensorFlow training across multiple workers. MultiWorkerMirroredStrategy synchronously replicates model variables on every device and coordinates updates through collective communication such as all-reduce. section 9.2.2

A distributed training implementation must:

  • Create the strategy with automatic collective communication so available hardware can be selected. section 9.2.2
  • Batch and shard the input pipeline, then create the model inside strategy.scope() so variables replicate correctly. section 9.2.2
  • Train with fit() outside the scope and save the completed model only from the chief worker. section 9.2.2

Two-worker deployment

A containerized TensorFlow script can run as a Kubeflow TFJob with two worker replicas, shared persistent storage, checkpoints, and a CNN model argument.

How Distributed Machine Learning Patterns covers it

How deep it goes
Explains strategy construction, scoped model creation, data sharding, chief-only saving, and containerized deployment.
Examples
Uses CNN variants, automatic data sharding, chief-worker model saving, Docker, persistent volumes, and a two-worker TFJob.
What it assumes
Assumes a locally trainable TensorFlow model and introduces the additional distributed strategy, input, saving, and deployment logic.
What you can do after
Builds and deploys synchronous multi-worker TensorFlow training through strategy scopes, Docker, and Kubeflow TFJobs.
How it connects
Connects synchronous training with collective communication, all-reduce, distributed input pipelines, Kubernetes, and Kubeflow.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Distributed Machine Learning Patterns. The section links point to the parts of the book it draws on.