-
Notifications
You must be signed in to change notification settings - Fork 18
/
setup.py
81 lines (70 loc) · 2.44 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
from setuptools import dist
dist.Distribution().fetch_build_eggs(['cython'])
from setuptools import find_packages, setup
import os
import torch
from torch.utils.cpp_extension import (BuildExtension, CppExtension,
CUDAExtension)
def readme():
with open('README.md', encoding='utf-8') as f:
content = f.read()
return content
def make_cuda_ext(name, module, sources, sources_cuda=[]):
define_macros = []
extra_compile_args = {'cxx': []}
if torch.cuda.is_available() or os.getenv('FORCE_CUDA', '0') == '1':
define_macros += [('WITH_CUDA', None)]
extension = CUDAExtension
extra_compile_args['nvcc'] = [
'-D__CUDA_NO_HALF_OPERATORS__',
'-D__CUDA_NO_HALF_CONVERSIONS__',
'-D__CUDA_NO_HALF2_OPERATORS__',
]
sources += sources_cuda
else:
print(f'Compiling {name} without CUDA')
extension = CppExtension
raise EnvironmentError('CUDA is required to compile vedadet')
return extension(
name=f'{module}.{name}',
sources=[os.path.join(*module.split('.'), p) for p in sources],
define_macros=define_macros,
extra_compile_args=extra_compile_args)
if __name__ == '__main__':
setup(
name='flexinfer',
version='2.0.0',
description='Python Inference SDK',
url='https://github.com/Media-Smart/flexinfer',
author='Yichao Xiong, Hongxiang Cai',
author_email='[email protected], [email protected]',
classifiers=[
'Programming Language :: Python :: 3',
'Operating System :: Linux',
'License :: OSI Approved :: Apache Software License',
],
keywords='computer vision, inference',
packages=find_packages(),
package_data={'flexinfer.ops': ['*/*.so']},
setup_requires=[
'tensorrt',
'torch',
'volksdep',
],
install_requires=[
'addict',
'yapf',
'numpy',
'opencv-python',
],
ext_modules=[
make_cuda_ext(
name='nms_ext',
module='flexinfer.ops.nms',
sources=['src/nms_ext.cpp', 'src/cpu/nms_cpu.cpp'],
sources_cuda=[
'src/cuda/nms_cuda.cpp', 'src/cuda/nms_kernel.cu'
]),
],
cmdclass={'build_ext': BuildExtension},
zip_safe=False)