Why is Training Slow?
Deep learning does a huge number of calculations. Training time depends on the hardware, the model size, the data pipeline and how you configure things. Here are the easy wins.
1. Use a GPU or TPU
If the list is empty, you are on a CPU. In Google Colab, choose a GPU runtime. TensorFlow uses an available GPU automatically.
2. Fix the Input Pipeline
- Use
tf.datawithcache()andprefetch(tf.data.AUTOTUNE) - Use
num_parallel_calls=tf.data.AUTOTUNEinmap() - Read data from a fast disk, and avoid decoding images again and again
3. Larger Batch Size
A bigger batch uses the GPU better. Increase it until you run out of memory, and consider raising the learning rate a little.
4. Mixed Precision
Modern GPUs calculate much faster with 16-bit numbers. Mixed precision uses 16-bit for most operations and keeps 32-bit where needed for stability, giving large speedups on supported GPUs with little accuracy loss.
5. Multiple GPUs
6. Other Tips
| Tip | Effect |
|---|---|
| Smaller input images | Big speedup, small accuracy cost |
| Transfer learning | Far fewer weights to train |
| EarlyStopping | Avoid useless epochs |
| Lighter model (MobileNet) | Faster training and inference |
| Train on a sample first | Debug your code in seconds |
Find the Bottleneck with the Profiler
Open TensorBoard and look at the Profile tab to see if the GPU is waiting for data.
Conclusion
Fast training comes from good hardware use, an efficient data pipeline and techniques such as mixed precision.

