pytorch/docs/libtorch.rst
Jesse Hellemn 4aee92833c Update libtorch docs (#21150)
Summary:
Fixes https://github.com/pytorch/pytorch/issues/20271
Pull Request resolved: https://github.com/pytorch/pytorch/pull/21150

Differential Revision: D15559590

Pulled By: pjh5

fbshipit-source-id: 4063bf91464425e8efe4765dc17bb7e9b7bfccc7
2019-05-30 12:49:56 -07:00

37 lines
1.2 KiB
ReStructuredText

libtorch (C++-only)
===================
The core of pytorch does not depend on Python. A
CMake-based build system compiles the C++ source code into a shared
object, libtorch.so.
Building libtorch
-----------------
You can use a python script/module located in tools package to build libtorch
::
cd <pytorch_root>
# Make a new folder to build in to avoid polluting the source directories
mkdir build_libtorch && cd build_libtorch
# You might need to export some required environment variables here.
Normally setup.py sets good default env variables, but you'll have to do
that manually.
python ../tools/build_libtorch.py
Alternatively, you can call setup.py normally and then copy the built cpp libraries. This method may have side effects to your active Python installation.
::
cd <pytorch_root>
python setup.py build
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"`.
Note that we are working on eliminating tools/build_pytorch_libs.sh in favor of a unified cmake build.