liveBook · Manning

TPU

As explained in Deep Learning with Python, Third Edition

A specialized tensor-processing chip and cloud-accessible hardware accelerator used to speed up machine learning training.

A Tensor Processing Unit (TPU) is a specialized application-specific chip for deep learning. Google provides TPU access through Google Cloud and Colab as an alternative to GPUs when training speed and cost matter. section 18.2.3

Use TPU training with these practical considerations:

  • Expect substantial speed gains: TPU v2 on Colab typically trains about 15× faster than an NVIDIA P100 GPU and averages about 3× better cost-effectiveness. section 18.2.3
  • Select a TPU runtime in Colab, or use TPU v3 through v5 on Google Cloud for more serious training runs. section 18.2.3
  • Configure distribution before creating the model when using Keras with the JAX backend. section 18.2.3
  • Watch input throughput: fast TPU computation can make Google Cloud Storage reads the bottleneck, so cache small datasets in memory. section 18.2.3
  • Use very large batches to keep TPU cores busy; small models may require batches exceeding 10,000 samples. section 18.2.3

Starting TPU distribution

With a TPU-enabled notebook and the Keras JAX backend, configure a DataParallel or ModelParallel distribution before creating the model: keras.distribution.set_distribution(distribution). section 18.2.3

model.compile(..., steps_per_execution=8)

Increase work completed per call with step fusing: model.compile(..., steps_per_execution=8). section 18.2.3

How Deep Learning with Python, Third Edition covers it

How deep it goes
Explains hardware choice, runtime setup, distribution, input bottlenecks, caching, and batch-size requirements.
Examples
Uses Colab TPU v2, Google Cloud TPU v3 through v5, Keras distribution, dataset caching, and large-batch training.
What it assumes
Assumes familiarity with Keras model training and introduces TPU distribution as the additional configuration step.
What you can do after
Operate/configure TPU training in Colab or Google Cloud through Keras distribution and address data-throughput limitations.
How it connects
Connects TPUs with GPUs, ASICs, XLA, Keras, JAX, distributed training, and Google Cloud Storage.

Also explained in

Compare how 5 books explain TPU →

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.