PROFESSIONAL-MACHINE-LEARNING-ENGINEER · Question #114
You recently developed a deep learning model using Keras, and now you are experimenting with different training strategies. First, you trained the model using a single GPU, but the training process…
The correct answer is D. Increase the batch size. When distributing Keras model training across multiple GPUs using tf.distribute.MirroredStrategy, if no speedup is observed, the primary issue is often an insufficient global batch size.
Question
Options
- ADistribute the dataset with tf.distribute.Strategy.experimental_distribute_dataset
- BCreate a custom training loop.
- CUse a TPU with tf.distribute.TPUStrategy.
- DIncrease the batch size.
How the community answered
(61 responses)- A3% (2)
- B7% (4)
- C13% (8)
- D77% (47)
Why each option
When distributing Keras model training across multiple GPUs using tf.distribute.MirroredStrategy, if no speedup is observed, the primary issue is often an insufficient global batch size.
`tf.distribute.Strategy.experimental_distribute_dataset` is typically used to ensure the dataset is distributed correctly across workers, but the immediate problem described suggests a batch size issue rather than a fundamental dataset distribution flaw within a single host's MirroredStrategy setup.
Creating a custom training loop might offer more control but doesn't inherently address the performance issue with MirroredStrategy not showing speedup; the strategy is designed to work efficiently with standard Keras `model.fit()` given proper batch sizing.
While TPUs are powerful, the problem is specifically about optimizing the current GPU setup with `MirroredStrategy`, not switching to different hardware; switching to TPUs would be a different solution, not a fix for the observed issue with GPU utilization.
tf.distribute.MirroredStrategy replicates the model on each GPU, and each replica processes a slice of the global batch. To fully utilize multiple GPUs and benefit from distributed training, the global batch size must be increased proportionally to the number of devices to ensure each GPU has sufficient work and the computational benefits of parallelism are realized.
Concept tested: Distributed training batch size optimization
Source: https://www.tensorflow.org/guide/distributed_training#mirroredstrategy
Topics
Community Discussion
No community discussion yet for this question.