|
|
import glob |
|
|
import os |
|
|
import os.path as osp |
|
|
import platform |
|
|
import sys |
|
|
|
|
|
from setuptools import find_packages, setup |
|
|
|
|
|
__version__ = "1.4.0" |
|
|
|
|
|
|
|
|
URL = "https://github.com/nerfstudio-project/gsplat" |
|
|
|
|
|
BUILD_NO_CUDA = os.getenv("BUILD_NO_CUDA", "0") == "1" |
|
|
WITH_SYMBOLS = os.getenv("WITH_SYMBOLS", "0") == "1" |
|
|
LINE_INFO = os.getenv("LINE_INFO", "0") == "1" |
|
|
|
|
|
|
|
|
def get_ext(): |
|
|
from torch.utils.cpp_extension import BuildExtension |
|
|
|
|
|
return BuildExtension.with_options(no_python_abi_suffix=True, use_ninja=False) |
|
|
|
|
|
|
|
|
def get_extensions(): |
|
|
import torch |
|
|
from torch.__config__ import parallel_info |
|
|
from torch.utils.cpp_extension import CUDAExtension |
|
|
|
|
|
|
|
|
if "TORCH_CUDA_ARCH_LIST" not in os.environ: |
|
|
|
|
|
os.environ["TORCH_CUDA_ARCH_LIST"] = "7.5;8.0;8.6" |
|
|
|
|
|
extensions_dir = osp.join("src", "gsplat", "cuda", "csrc") |
|
|
sources = glob.glob(osp.join(extensions_dir, "*.cu")) + glob.glob( |
|
|
osp.join(extensions_dir, "*.cpp") |
|
|
) |
|
|
|
|
|
|
|
|
sources = [path for path in sources if "hip" not in path] |
|
|
|
|
|
undef_macros = [] |
|
|
define_macros = [] |
|
|
|
|
|
if sys.platform == "win32": |
|
|
define_macros += [("gsplat_EXPORTS", None)] |
|
|
|
|
|
extra_compile_args = {"cxx": ["-O3"]} |
|
|
if not os.name == "nt": |
|
|
extra_compile_args["cxx"] += ["-Wno-sign-compare"] |
|
|
extra_link_args = [] if WITH_SYMBOLS else ["-s"] |
|
|
|
|
|
info = parallel_info() |
|
|
if ( |
|
|
"backend: OpenMP" in info |
|
|
and "OpenMP not found" not in info |
|
|
and sys.platform != "darwin" |
|
|
): |
|
|
extra_compile_args["cxx"] += ["-DAT_PARALLEL_OPENMP"] |
|
|
if sys.platform == "win32": |
|
|
extra_compile_args["cxx"] += ["/openmp"] |
|
|
else: |
|
|
extra_compile_args["cxx"] += ["-fopenmp"] |
|
|
else: |
|
|
print("Compiling without OpenMP...") |
|
|
|
|
|
|
|
|
if sys.platform == "darwin" and platform.machine() == "arm64": |
|
|
extra_compile_args["cxx"] += ["-arch", "arm64"] |
|
|
extra_link_args += ["-arch", "arm64"] |
|
|
|
|
|
nvcc_flags = os.getenv("NVCC_FLAGS", "") |
|
|
nvcc_flags = [] if nvcc_flags == "" else nvcc_flags.split(" ") |
|
|
nvcc_flags += ["-O3", "--use_fast_math"] |
|
|
if LINE_INFO: |
|
|
nvcc_flags += ["-lineinfo"] |
|
|
if torch.version.hip: |
|
|
|
|
|
|
|
|
define_macros += [("USE_ROCM", None)] |
|
|
undef_macros += ["__HIP_NO_HALF_CONVERSIONS__"] |
|
|
else: |
|
|
nvcc_flags += ["--expt-relaxed-constexpr"] |
|
|
extra_compile_args["nvcc"] = nvcc_flags |
|
|
if sys.platform == "win32": |
|
|
extra_compile_args["nvcc"] += ["-DWIN32_LEAN_AND_MEAN"] |
|
|
|
|
|
extension = CUDAExtension( |
|
|
"csrc", |
|
|
sources, |
|
|
include_dirs=[ |
|
|
extensions_dir, |
|
|
osp.join(extensions_dir, "third_party", "glm"), |
|
|
], |
|
|
define_macros=define_macros, |
|
|
undef_macros=undef_macros, |
|
|
extra_compile_args=extra_compile_args, |
|
|
extra_link_args=extra_link_args, |
|
|
) |
|
|
|
|
|
return [extension] |
|
|
|
|
|
|
|
|
setup( |
|
|
name="gsplat", |
|
|
version=__version__, |
|
|
description=" Python package for differentiable rasterization of gaussians", |
|
|
url=URL, |
|
|
download_url=f"{URL}/archive/gsplat-{__version__}.tar.gz", |
|
|
python_requires=">=3.7", |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ext_modules=get_extensions() if not BUILD_NO_CUDA else [], |
|
|
cmdclass={"build_ext": get_ext()} if not BUILD_NO_CUDA else {}, |
|
|
packages=find_packages(where="src"), |
|
|
package_dir={"": "src"}, |
|
|
|
|
|
include_package_data=True, |
|
|
) |
|
|
|