39  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.

Section 39.1 asks how to run the book’s notebooks locally so that a result does not depend on hidden state. Section 39.2 asks how to run them with nothing installed, on Colab or Kaggle. Section 39.3 asks when to rent an accelerator and how to count what a run costs. Section 39.4 asks which hardware to buy, given what limits the workload. Section 39.5 asks where to find models, datasets, and benchmarks, and how to judge and record them. Section 39.6 asks how to spread training over several accelerators when one is not enough. Section 39.7 asks how to serve a model to many users at once. Section 39.8 asks how this book is built from its sources and how to propose a change to it.

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