Chapter 27

27 Tools for Deep Learning

Most readers first run this book's code on a laptop or in a browser tab: open a notebook, run the cells, change the learning rate, and run them again. Sooner or later something no longer fits. A model needs more memory than the laptop has, a training run would take a week, or an open language model downloaded for a weekend project writes three words per second. Each of these looks like a question about which product to use. Underneath, the same few questions recur: does the job fit in memory, what limits its speed, and what will a finished result cost?

Products change within months, but the answers rest on a few rules that last longer. Memory decides what can run at all, so we check that a job fits before we make it faster. When a language model generates text, it reads every weight it uses from memory once for each new token, so memory bandwidth sets the speed of generation. The cheapest machine per hour does not give the cheapest experiment if it runs the job more slowly or the job fails partway, so we compare the cost of a completed result. And a result that cannot be rerun from what was recorded cannot be checked or built on, so reproducibility belongs to the workflow from the first cell. In Chapter 13 a program was limited by its arithmetic, by its memory bandwidth, or by the overhead of issuing operations. These rules apply that model to the decisions of what to run, rent, buy, and deploy.

The chapter moves from a single interactive notebook to multi-machine training and production serving. We begin with where code runs day to day: managing Jupyter kernel state and local uv environments so results do not depend on hidden execution history (Section 27.1), running notebooks with zero local setup on Colab and Kaggle (Section 27.2), and pricing rented cloud accelerators by the total cost of a completed result (Section 27.3). Next, we turn to hardware and external artifacts: choosing what to buy from memory capacity, bandwidth, and compute bounds (Section 27.4), and discovering, evaluating, pinning, and licensing pretrained models and datasets from public hubs (Section 27.5). Finally, we scale across machines and contributors, partitioning training across multiple accelerators (Section 27.6), serving concurrent users under latency targets (Section 27.7), and seeing how this book itself is built and maintained from single-source Markdown files (Section 27.8).

Prices, product names, quotas, and library versions change quickly. The sections that quote them give the date of each quote; check them before use.

The generated utility and d2l API documents remain searchable HTML reference pages. They are not part of the teaching sequence or the PDF edition.

Resources and Further Reading#

The resources below accompany the sections of this chapter, from working on one machine to training and serving at scale. All are freely accessible online.

Systems and scaling

Performance thinking

Surveys

Staying current