nerfstudio-project / nerfacc

A General NeRF Acceleration Toolbox in PyTorch.
https://www.nerfacc.com/
Other
1.38k stars 112 forks source link

Cannot compile render_transmittance_cub.cu & pybind.cu #111

Closed antoine-crettenand closed 1 year ago

antoine-crettenand commented 1 year ago

Hi,

First, thank you for your amazing work!

I'm currently working with Vanilla NeuS and NerfAcc but I'm running into a strange issue. When I run my script for the first time, it fails at the compilation of the cuda objects render_transmittance_cub.cu & pybind.cu (following a call to ray_marching() ).

I wonder if someone had the same issue ? I cannot understand where it could come from. I made sure to have all the different requirements and CUDA modules properly installed.

Traceback (most recent call last):
  File "/home/users/c/crettean/improved_NeuS/run.py", line 416, in <module>
    runner.train()
  File "/home/users/c/crettean/improved_NeuS/run.py", line 126, in train
    render_out = self.renderer.render(rays_o, rays_d, near, far,
  File "/home/users/c/crettean/improved_NeuS/models/renderer.py", line 358, in render
    packed_info, t_starts, t_ends = ray_marching(
  File "/opt/ebsofts/PyTorch/1.11.0-foss-2021a-CUDA-11.3.1/lib/python3.9/site-packages/torch/autograd/grad_mode.py", line 27, in decorate_context
    return func(*args, **kwargs)
  File "/home/users/c/crettean/.local/lib/python3.9/site-packages/nerfacc/ray_marching.py", line 174, in ray_marching
    contraction_type = ContractionType.AABB.to_cpp_version()
  File "/home/users/c/crettean/.local/lib/python3.9/site-packages/nerfacc/contraction.py", line 62, in to_cpp_version
    return _C.ContractionTypeGetter(self.value)
  File "/home/users/c/crettean/.local/lib/python3.9/site-packages/nerfacc/cuda/__init__.py", line 11, in call_cuda
    from ._backend import _C
  File "/home/users/c/crettean/.local/lib/python3.9/site-packages/nerfacc/cuda/_backend.py", line 82, in <module>
    _C = load(
  File "/opt/ebsofts/PyTorch/1.11.0-foss-2021a-CUDA-11.3.1/lib/python3.9/site-packages/torch/utils/cpp_extension.py", line 1144, in load
    return _jit_compile(
  File "/opt/ebsofts/PyTorch/1.11.0-foss-2021a-CUDA-11.3.1/lib/python3.9/site-packages/torch/utils/cpp_extension.py", line 1357, in _jit_compile
    _write_ninja_file_and_build_library(
  File "/opt/ebsofts/PyTorch/1.11.0-foss-2021a-CUDA-11.3.1/lib/python3.9/site-packages/torch/utils/cpp_extension.py", line 1469, in _write_ninja_file_and_build_library
    _run_ninja_build(
  File "/opt/ebsofts/PyTorch/1.11.0-foss-2021a-CUDA-11.3.1/lib/python3.9/site-packages/torch/utils/cpp_extension.py", line 1756, in _run_ninja_build
    raise RuntimeError(message) from e
RuntimeError: Error building extension 'nerfacc_cuda': [1/6] /opt/ebsofts/CUDA/11.3.1/bin/nvcc  -DTORCH_EXTENSION_NAME=nerfacc_cuda -DTORCH_API_INCLUDE_EXTENSION_H -DPYBIND11_COMPILER_TYPE=\"_gcc\" -DPYBIND11_STDLIB=\"_libstdcpp\" -DPYBIND11_BUILD_ABI=\"_cxxabi1014\" -isystem /opt/ebsofts/PyTorch/1.11.0-foss-2021a-CUDA-11.3.1/lib/python3.9/site-packages/torch/include -isystem /opt/ebsofts/PyTorch/1.11.0-foss-2021a-CUDA-11.3.1/lib/python3.9/site-packages/torch/include/torch/csrc/api/include -isystem /opt/ebsofts/PyTorch/1.11.0-foss-2021a-CUDA-11.3.1/lib/python3.9/site-packages/torch/include/TH -isystem /opt/ebsofts/PyTorch/1.11.0-foss-2021a-CUDA-11.3.1/lib/python3.9/site-packages/torch/include/THC -isystem /opt/ebsofts/CUDA/11.3.1/include -isystem /opt/ebsofts/Python/3.9.5-GCCcore-10.3.0/include/python3.9 -D_GLIBCXX_USE_CXX11_ABI=1 -D__CUDA_NO_HALF_OPERATORS__ -D__CUDA_NO_HALF_CONVERSIONS__ -D__CUDA_NO_BFLOAT16_CONVERSIONS__ -D__CUDA_NO_HALF2_OPERATORS__ --expt-relaxed-constexpr -gencode=arch=compute_75,code=compute_75 -gencode=arch=compute_75,code=sm_75 --compiler-options '-fPIC' -O3 -std=c++14 -c /home/users/c/crettean/.local/lib/python3.9/site-packages/nerfacc/cuda/csrc/render_transmittance_cub.cu -o render_transmittance_cub.cuda.o 
FAILED: render_transmittance_cub.cuda.o 
/opt/ebsofts/CUDA/11.3.1/bin/nvcc  -DTORCH_EXTENSION_NAME=nerfacc_cuda -DTORCH_API_INCLUDE_EXTENSION_H -DPYBIND11_COMPILER_TYPE=\"_gcc\" -DPYBIND11_STDLIB=\"_libstdcpp\" -DPYBIND11_BUILD_ABI=\"_cxxabi1014\" -isystem /opt/ebsofts/PyTorch/1.11.0-foss-2021a-CUDA-11.3.1/lib/python3.9/site-packages/torch/include -isystem /opt/ebsofts/PyTorch/1.11.0-foss-2021a-CUDA-11.3.1/lib/python3.9/site-packages/torch/include/torch/csrc/api/include -isystem /opt/ebsofts/PyTorch/1.11.0-foss-2021a-CUDA-11.3.1/lib/python3.9/site-packages/torch/include/TH -isystem /opt/ebsofts/PyTorch/1.11.0-foss-2021a-CUDA-11.3.1/lib/python3.9/site-packages/torch/include/THC -isystem /opt/ebsofts/CUDA/11.3.1/include -isystem /opt/ebsofts/Python/3.9.5-GCCcore-10.3.0/include/python3.9 -D_GLIBCXX_USE_CXX11_ABI=1 -D__CUDA_NO_HALF_OPERATORS__ -D__CUDA_NO_HALF_CONVERSIONS__ -D__CUDA_NO_BFLOAT16_CONVERSIONS__ -D__CUDA_NO_HALF2_OPERATORS__ --expt-relaxed-constexpr -gencode=arch=compute_75,code=compute_75 -gencode=arch=compute_75,code=sm_75 --compiler-options '-fPIC' -O3 -std=c++14 -c /home/users/c/crettean/.local/lib/python3.9/site-packages/nerfacc/cuda/csrc/render_transmittance_cub.cu -o render_transmittance_cub.cuda.o 

Moreover I get this error which could be linked to the previous error :

/home/users/c/crettean/.local/lib/python3.9/site-packages/nerfacc/cuda/csrc/include/helpers_cuda.h:27:75: attention: \ en fin de ligne à la fin du fichier

   27 | #define CUB_WRAPPER(func, ...) do {                                       \
      |                                                                            
/home/users/c/crettean/.local/lib/python3.9/site-packages/nerfacc/cuda/csrc/render_transmittance_cub.cu:8:29: erreur: missing binary operator before token "("
    8 | #if CUB_SUPPORTS_SCAN_BY_KEY()
      |                             ^
/home/users/c/crettean/.local/lib/python3.9/site-packages/nerfacc/cuda/csrc/render_transmittance_cub.cu:18:29: erreur: missing binary operator before token "("
   18 | #if CUB_SUPPORTS_SCAN_BY_KEY()
      |                             ^
/home/users/c/crettean/.local/lib/python3.9/site-packages/nerfacc/cuda/csrc/render_transmittance_cub.cu:61:29: erreur: missing binary operator before token "("
   61 | #if CUB_SUPPORTS_SCAN_BY_KEY()
      |                             ^
/home/users/c/crettean/.local/lib/python3.9/site-packages/nerfacc/cuda/csrc/render_transmittance_cub.cu:98:29: erreur: missing binary operator before token "("
   98 | #if CUB_SUPPORTS_SCAN_BY_KEY()
      |                             ^
/home/users/c/crettean/.local/lib/python3.9/site-packages/nerfacc/cuda/csrc/render_transmittance_cub.cu:124:29: erreur: missing binary operator before token "("
  124 | #if CUB_SUPPORTS_SCAN_BY_KEY()
      |                             ^
/home/users/c/crettean/.local/lib/python3.9/site-packages/nerfacc/cuda/csrc/render_transmittance_cub.cu:155:29: erreur: missing binary operator before token "("
  155 | #if CUB_SUPPORTS_SCAN_BY_KEY()
      | 
liruilong940607 commented 1 year ago

Hi thanks for reporting this issue.

A quick work around is to use nerfacc==0.2.4, which should not have this issue.

I will look into this soon

zjhthu commented 1 year ago

Update PyTorch to 1.12 can resolve this problem. Because the macro CUB_SUPPORTS_SCAN_BY_KEY is introduced after PyTorch 1.11.

liruilong940607 commented 1 year ago

should be resolved in nerfacc==0.3.2