CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutSign UpSign In
hukaixuan19970627

Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place. Commercial Alternative to JupyterHub.

GitHub Repository: hukaixuan19970627/yolov5_obb
Path: blob/master/utils/nms_rotated/setup.py
Views: 475
1
#!/usr/bin/env python
2
import os
3
import subprocess
4
import time
5
from setuptools import find_packages, setup
6
7
import torch
8
from torch.utils.cpp_extension import (BuildExtension, CppExtension,
9
CUDAExtension)
10
def make_cuda_ext(name, module, sources, sources_cuda=[]):
11
12
define_macros = []
13
extra_compile_args = {'cxx': []}
14
15
if torch.cuda.is_available() or os.getenv('FORCE_CUDA', '0') == '1':
16
define_macros += [('WITH_CUDA', None)]
17
extension = CUDAExtension
18
extra_compile_args['nvcc'] = [
19
'-D__CUDA_NO_HALF_OPERATORS__',
20
'-D__CUDA_NO_HALF_CONVERSIONS__',
21
'-D__CUDA_NO_HALF2_OPERATORS__',
22
]
23
sources += sources_cuda
24
else:
25
print(f'Compiling {name} without CUDA')
26
extension = CppExtension
27
# raise EnvironmentError('CUDA is required to compile MMDetection!')
28
29
return extension(
30
name=f'{module}.{name}',
31
sources=[os.path.join(*module.split('.'), p) for p in sources],
32
define_macros=define_macros,
33
extra_compile_args=extra_compile_args)
34
35
# python setup.py develop
36
if __name__ == '__main__':
37
#write_version_py()
38
setup(
39
name='nms_rotated',
40
ext_modules=[
41
make_cuda_ext(
42
name='nms_rotated_ext',
43
module='',
44
sources=[
45
'src/nms_rotated_cpu.cpp',
46
'src/nms_rotated_ext.cpp'
47
],
48
sources_cuda=[
49
'src/nms_rotated_cuda.cu',
50
'src/poly_nms_cuda.cu',
51
]),
52
],
53
cmdclass={'build_ext': BuildExtension},
54
zip_safe=False)
55