This chapter covers:
- Various options to deploy PyTorch models.
- Deploying a server for our models.
- Exporting our models.
- Making good use of the PyTorch JIT with all of this.
- Running exported models from C++.
- Natively implementing models in C++.
- Running our models on mobile.
In Part I we learned a lot about models and Part II left us with a detailed path towards good models for a particular problem. Now that we have these great models, we need to take them where they can be useful. Maintaining infrastructure for executing inference of deep learning models at scale can be impactful from an architectural as well as cost standpoint. While PyTorch started off as a framework focused on research, starting with the 1.0 release a set of production-oriented features were added that today make PyTorch an ideal end-to-end platform from resarch to large-scale production.
What deploying to production means to use will vary with the use case:
· Perhaps the most natural deployment for the models we developed in Part II is that we might set up a network service providing access to our models. We do this in two versions using lightweight Python web frameworks, Flask [1: http://flask.pocoo.org] and Sanic [2: https://sanicframework.org]. The first is arguably one of the most popular of these frameworks and the latter is similar in spirit but leverages Python’s new async/await support for asynchronous operations for efficiency.