blob: 6b5c411f536316eca690fae9298a8333975c304e (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
|
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>
# export some required environment variables
python -m tools.build_libtorch
Alternatively, you can invoke a shell script in the same directory to achieve the same goal
::
cd <pytorch_root>
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"`.
Note that we are working on eliminating tools/build_pytorch_libs.sh in favor of a unified cmake build.
|