forked from pytorch/pytorch
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild_libtorch.py
31 lines (25 loc) · 965 Bytes
/
build_libtorch.py
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
30
31
import argparse
import os
import shlex
import subprocess
import sys
from setup_helpers.cuda import USE_CUDA
if __name__ == '__main__':
# Placeholder for future interface. For now just gives a nice -h.
parser = argparse.ArgumentParser(description='Build libtorch')
options = parser.parse_args()
os.environ['BUILD_TORCH'] = 'ON'
os.environ['BUILD_TEST'] = 'ON'
os.environ['ONNX_NAMESPACE'] = 'onnx_torch'
os.environ['PYTORCH_PYTHON'] = sys.executable
tools_path = os.path.dirname(os.path.abspath(__file__))
build_pytorch_libs = os.path.join(tools_path, 'build_pytorch_libs.sh')
command = [build_pytorch_libs, '--use-nnpack']
if USE_CUDA:
command.append('--use-cuda')
if os.environ.get('USE_CUDA_STATIC_LINK', False):
command.append('--cuda-static-link')
command.append('caffe2')
sys.stdout.flush()
sys.stderr.flush()
subprocess.check_call(command, universal_newlines=True)