Document current deploy cpython build #56490 (#56600)

Summary:
Call out the issues with cpython deps and suggest a workaround.

Fixes https://github.com/pytorch/pytorch/issues/56490

Pull Request resolved: https://github.com/pytorch/pytorch/pull/56600

Reviewed By: albanD

Differential Revision: D27920647

Pulled By: wconstab

fbshipit-source-id: 61a53a176eaf42a6166d649d3cb0fdfa2489e9d2
This commit is contained in:
Will Constable
2021-04-22 09:00:33 -07:00
committed by Facebook GitHub Bot
parent 78022aa62c
commit 21fd5f4b79
2 changed files with 13 additions and 1 deletions

View File

@ -283,7 +283,7 @@ option(USE_TBB "Use TBB" OFF)
option(ONNX_ML "Enable traditional ONNX ML API." ON)
option(HAVE_SOVERSION "Whether to add SOVERSION to the shared objects" OFF)
cmake_dependent_option(
USE_DEPLOY "Build embedded torch::deploy interpreter" OFF
USE_DEPLOY "Build embedded torch::deploy interpreter. See torch/csrc/deploy/README.md for more info." OFF
"BUILD_PYTHON" OFF)
cmake_dependent_option(USE_CCACHE "Attempt using CCache to wrap the compilation" ON "UNIX" OFF)

View File

@ -8,3 +8,15 @@ This is an internal library used behind the scenes to enable multiple python int
a single deploy runtime. libinterpreter.so is DLOPENed multiple times by the deploy library.
Each copy of libinterpreter exposes a simple interpreter interface but hides its python and other
internal symbols, preventing the different python instances from seeing each other.
# CPython build
Torch Deploy builds CPython from source as part of the embedded python interpreter. CPython has a flexible build system that builds successfully with or without a variety of dependencies installed - if missing, the resulting CPython build simply omits optional functionality, meaning some stdlib modules/libs are not present.
Currently, the torch deploy build setup assumes the full CPython build is present. This matters because there is a [hardcoded list of python stdlib modules](https://github.com/pytorch/pytorch/blob/2662e34e9287a72e96dabb590e7732f9d4a6b37b/torch/csrc/deploy/interpreter/interpreter_impl.cpp#L35) that are explicitly loaded from the embedded binary at runtime.
### rebuilding CPython after installing missing dependencies
Becuase CPython builds successfully when optional dependencies are missing, the cmake wrapper currently doesn't know if you need to rebuild CPython after adding missing dependencies (or whether dependencies were missing in the first place).
To be safe, install the [complete list of dependencies for CPython](https://devguide.python.org/setup/#install-dependencies) for your platform, before trying to build torch with USE_DEPLOY=1.
If you already built CPython without all the dependencies and want to fix it, just blow away the CPython folder under torch/csrc/deploy/third_party, install the missing system dependencies, and re-attempt the pytorch build command.