-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathsetup.py
63 lines (57 loc) · 1.65 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
from setuptools import setup
from torch.utils.cpp_extension import BuildExtension
setup_kwargs = {
'name': 'torchmcubes',
'version': '0.1.0',
'description': 'torchmcubes: marching cubes for PyTorch',
'license': 'MIT',
'author': 'Tatsuya Yatagawa',
'author_email': 'tatsy.mail@gmail.com',
'packages': [
'torchmcubes'
],
'classifiers': [
'Programming Language :: Python :: 3.7',
'Programming Language :: Python :: 3.8',
'Programming Language :: Python :: 3.9',
]
}
try:
from torch.utils.cpp_extension import CUDAExtension
setup_kwargs.update({
'ext_modules': [
CUDAExtension(
'torchmcubes_module',
[
'cxx/pscan.cu',
'cxx/mcubes.cpp',
'cxx/mcubes_cpu.cpp',
'cxx/mcubes_cuda.cu',
'cxx/grid_interp_cpu.cpp',
'cxx/grid_interp_cuda.cu',
],
extra_compile_args=['-DWITH_CUDA'],
)
],
'cmdclass': {
'build_ext': BuildExtension
}
})
setup(**setup_kwargs)
except:
print('CUDA environment was not successfully loaded!')
print('Build only CPU module!')
from torch.utils.cpp_extension import CppExtension
setup_kwargs.update({
'ext_modules': [
CppExtension('torchmcubes_module', [
'cxx/mcubes.cpp',
'cxx/mcubes_cpu.cpp',
'cxx/grid_interp_cpu.cpp',
])
],
'cmdclass': {
'build_ext': BuildExtension
}
})
setup(**setup_kwargs)