-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathsetup.py
More file actions
53 lines (43 loc) · 1.66 KB
/
Copy pathsetup.py
File metadata and controls
53 lines (43 loc) · 1.66 KB
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
"""Build script for dpvo native CUDA extensions.
When installed via Pixi, dpvo is treated as a pure-Python package.
The package's custom CUDA kernels are built explicitly with:
python setup.py build_ext --inplace
inside the activated Pixi environment, while `lietorch` comes from a
prebuilt conda package.
"""
import os
import sys
from setuptools import setup
if "build_ext" in sys.argv:
import torch
from torch.utils.cpp_extension import BuildExtension, CUDAExtension
if not torch.cuda.is_available():
raise RuntimeError("CUDA not found, cannot compile dpvo native extensions")
root = os.path.dirname(os.path.abspath(__file__))
conda_prefix = os.environ.get("CONDA_PREFIX", "")
if not os.environ.get("TORCH_CUDA_ARCH_LIST"):
cap = torch.cuda.get_device_capability()
arch = f"{cap[0]}.{cap[1]}+PTX"
os.environ["TORCH_CUDA_ARCH_LIST"] = arch
print(f"Auto-detected CUDA arch: {arch}")
setup(
ext_modules=[
CUDAExtension(
"dpvo._cuda_corr",
sources=[
"dpvo/altcorr/correlation.cpp",
"dpvo/altcorr/correlation_kernel.cu",
],
extra_compile_args={"cxx": ["-O3"], "nvcc": ["-O3"]},
),
CUDAExtension(
"dpvo._cuda_ba",
sources=["dpvo/fastba/ba.cpp", "dpvo/fastba/ba_cuda.cu", "dpvo/fastba/block_e.cu"],
include_dirs=[os.path.join(conda_prefix, "include", "eigen3")],
extra_compile_args={"cxx": ["-O3"], "nvcc": ["-O3"]},
),
],
cmdclass={"build_ext": BuildExtension},
)
else:
setup()