mirror of
https://github.com/pytorch/pytorch.git
synced 2025-10-20 21:14:14 +08:00
Summary: Pull Request resolved: https://github.com/pytorch/pytorch/pull/10272 Differential Revision: D9239337 Pulled By: anderspapitto fbshipit-source-id: 187b3acb7e85635d9b45a3dd82c98d86a2b51e70
24 lines
766 B
ReStructuredText
24 lines
766 B
ReStructuredText
libtorch (C++-only)
|
|
===================
|
|
|
|
The core of pytorch can be built and used without Python. A
|
|
CMake-based build system compiles the C++ source code into a shared
|
|
object, libtorch.so.
|
|
|
|
Building libtorch
|
|
-----------------
|
|
|
|
There is a script which wraps the CMake build. Invoke it with
|
|
|
|
::
|
|
cd pytorch
|
|
BUILD_TORCH=ON ONNX_NAMESPACE=onnx_torch bash tools/build_pytorch_libs.sh --use-nnpack caffe2
|
|
ls torch/lib/tmp_install # output is produced here
|
|
ls torch/lib/tmp_install/lib/libtorch.so # of particular interest
|
|
|
|
To produce libtorch.a rather than libtorch.so, set the environment variable `BUILD_SHARED_LIBS=OFF`.
|
|
|
|
To use ninja rather than make, set `CMAKE_GENERATOR="-GNinja" CMAKE_INSTALL="ninja install"`.
|
|
|
|
Future work will simplify this further.
|