| 5 | from torch.utils.cpp_extension import BuildExtension, CUDAExtension |
| 6 | |
| 7 | def make_cuda_ext(name, |
| 8 | module, |
| 9 | sources, |
| 10 | sources_cuda=[], |
| 11 | extra_args=[], |
| 12 | extra_include_path=[]): |
| 13 | |
| 14 | define_macros = [] |
| 15 | extra_compile_args = {'cxx': [] + extra_args} |
| 16 | |
| 17 | if torch.cuda.is_available() or os.getenv('FORCE_CUDA', '0') == '1': |
| 18 | define_macros += [('WITH_CUDA', None)] |
| 19 | extension = CUDAExtension |
| 20 | extra_compile_args['nvcc'] = extra_args + [ |
| 21 | '-D__CUDA_NO_HALF_OPERATORS__', |
| 22 | '-D__CUDA_NO_HALF_CONVERSIONS__', |
| 23 | '-D__CUDA_NO_HALF2_OPERATORS__', |
| 24 | "-gencode=arch=compute_35,code=sm_35", |
| 25 | "-gencode=arch=compute_37,code=sm_37", |
| 26 | "-gencode=arch=compute_50,code=sm_50", |
| 27 | "-gencode=arch=compute_52,code=sm_52", |
| 28 | "-gencode=arch=compute_53,code=sm_53", |
| 29 | "-gencode=arch=compute_60,code=sm_60", |
| 30 | "-gencode=arch=compute_61,code=sm_61", |
| 31 | "-gencode=arch=compute_62,code=sm_62", |
| 32 | "-gencode=arch=compute_75,code=sm_75", |
| 33 | "-gencode=arch=compute_80,code=sm_80", |
| 34 | "-gencode=arch=compute_86,code=sm_86", |
| 35 | ] |
| 36 | sources += sources_cuda |
| 37 | else: |
| 38 | raise EnvironmentError('CUDA is required to compile MMDetection!') |
| 39 | |
| 40 | return extension( |
| 41 | name='{}.{}'.format(module, name), |
| 42 | sources=[os.path.join(*module.split('.'), p) for p in sources], |
| 43 | include_dirs=extra_include_path, |
| 44 | define_macros=define_macros, |
| 45 | extra_compile_args=extra_compile_args, |
| 46 | ) |
| 47 | |
| 48 | setup( |
| 49 | name='voxel_pooling', |