forked from onnx/onnx-tensorrt
-
Notifications
You must be signed in to change notification settings - Fork 2
/
setup.py
109 lines (90 loc) · 3 KB
/
setup.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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
# Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved.
#
# Permission is hereby granted, free of charge, to any person obtaining a
# copy of this software and associated documentation files (the "Software"),
# to deal in the Software without restriction, including without limitation
# the rights to use, copy, modify, merge, publish, distribute, sublicense,
# and/or sell copies of the Software, and to permit persons to whom the
# Software is furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
# DEALINGS IN THE SOFTWARE.
import os
import argparse
from setuptools import setup, find_packages, Extension
__version__ = '0.1.0'
parser = argparse.ArgumentParser(description='Setup to build ONNX TensorRT parser')
parser.add_argument('action', nargs='*')
parser.add_argument('--build-lib', type=str,
help='A location of the build directory')
parser.add_argument('--include-dirs', type=str,
help='A location of the include directories, semicolon separated')
args = parser.parse_args()
print(args)
if args.build_lib == None:
args.build_lib = 'build'
TRT_ROOT = os.getenv('TRT_ROOT')
if TRT_ROOT == None:
INC_DIRS = []
else:
INC_DIRS = [TRT_ROOT + '/include']
SWIG_OPTS = [
'-c++',
'-modern',
'-builtin',
]
EXTRA_COMPILE_ARGS = [
'-std=c++11',
'-DUNIX',
'-D__UNIX',
'-m64',
'-fPIC',
'-O2',
'-w',
'-fmessage-length=0',
'-fno-strict-aliasing',
'-D_FORTIFY_SOURCE=2',
'-fstack-protector',
'--param=ssp-buffer-size=4',
'-Wformat',
'-Werror=format-security',
'-DNDEBUG',
'-g',
'-fwrapv',
'-Wall',
'-DSWIG',
]
EXTRA_LINK_ARGS = [
]
nv_onnx_parser_module = Extension(
'onnx_tensorrt.parser._nv_onnx_parser_bindings',
sources=['nv_onnx_parser_bindings.i'],
swig_opts=SWIG_OPTS,
extra_objects=[
args.build_lib + '/libnvonnxparser.so',
],
include_dirs=INC_DIRS,
extra_compile_args=EXTRA_COMPILE_ARGS,
extra_link_args=EXTRA_LINK_ARGS)
setup(name='onnx_tensorrt',
version=__version__,
description='TensorRT backend for ONNX',
author='NVIDIA Corporation',
author_email='[email protected]',
url='https://github.com/onnx/onnx-tensorrt',
packages=find_packages(),
ext_modules=[nv_onnx_parser_module],
install_requires=[
"numpy>=1.8.1",
"tensorrt>=3.0.0",
"onnx>=1.0.1",
"pycuda",
])