liveBook · Manning

Deployment

As explained in Deep Learning with PyTorch, Second Edition

The process of putting a trained model into a real runtime environment where it serves users or applications.

Training produces a model whose parameters are optimized for a task. Deployment puts that model where people or applications can use it—for example, on a server, in a larger application, or on a phone. The right route depends on where inference needs to run. section 1.5 section 17.0

Common routes serve different needs:

  • Use Gradio for a quick, shareable demo that lets people try the model. section 17.0
  • Use a Python web framework such as FastAPI to expose the model through a network API. section 17.0
  • Export to ONNX when the model must run with compatible processors, hardware, or cloud services. section 17.0
  • Consider LibTorch for C++ applications or ExecuTorch for mobile deployment. section 17.7

Deployment may also involve improving inference performance. PyTorch normally executes operations immediately in eager mode; production options include torch.compile for optimization and export tools for other runtimes. These choices are separate from training the model. section 1.5 section 17.7

Figure 1.2 Basic, high-level structure of a PyTorch project, with data loading, training, and deployment to production
figure

The project diagram places deployment after data loading and training, showing why a trained model is a milestone rather than the end of the workflow. section 1.5

How Deep Learning with PyTorch, Second Edition covers it

How deep it goes
Surveys deployment routes and performance tools, without giving a step-by-step procedure in the supplied passages.
Examples
Uses a Gradio demo, a FastAPI service, ONNX export, C++ applications, and mobile deployment as concrete options.
What it assumes
Assumes a trained model with parameters already optimized for its task.
What you can do after
Evaluate/understand which PyTorch deployment route fits a demo, web service, portable runtime, C++ application, or mobile device.
How it connects
Connects model training and inference with web APIs, model export, performance optimization, C++ integration, and mobile applications.

Also explained in

Compare how 23 books explain deployment →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Deep Learning with PyTorch, Second Edition. The section links point to the parts of the book it draws on.