liveBook · Manning

Data parallel

As explained in Deep Learning with Python, Third Edition

A distributed-training method where each device holds a full replica of the model and processes different sub-batches in parallel.

Data parallelism speeds up training by giving each GPU a complete copy of the model and a different share of each batch. For example, with two GPUs, a batch of 128 becomes two sub-batches of 64, processed at the same time. Training then merges the updates from the replicas. The model must fit on each device. section 18.2.1 section 18.4

keras.distribution.set_distribution(keras.distribution.DataParallel())

With Keras and JAX, set DataParallel before building the model to use data parallelism. section 18.2.2

A few practical checks matter:

  • To choose particular GPUs, list the available devices and pass their names to DataParallel. section 18.2.2
  • Keep the global batch large enough that each GPU receives enough work. Merging updates adds overhead: reported speedups are about 2× on two GPUs, 3.8× on four and 7.3× on eight. section 18.2.2
  • If the model cannot fit on one device, use model parallelism to split its variables and computation; the two approaches can also be combined. section 18.2.1 section 18.4

How Deep Learning with Python, Third Edition covers it

How deep it goes
Explains replicas and batch splitting with numbers, then gives Keras setup and performance caveats; does not detail update-merging mechanics.
Examples
Uses a batch of 128 split across two GPUs and Keras DataParallel calls for automatic or selected-device setup.
What it assumes
Assumes access to multiple GPUs and a model that fits on one device; introduces the replica-and-sub-batch mechanism from scratch.
What you can do after
Apply it via Keras DataParallel with JAX, selecting devices when needed and checking that each GPU receives enough data.
How it connects
Contrasts model parallelism with data parallelism and connects distributed training to batch size and GPU utilization.

Also explained in

Compare how 8 books explain data parallel →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Deep Learning with Python, Third Edition. The section links point to the parts of the book it draws on.