nerfstudio-project / nerfacc

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

error: name must be a namespace name when building CPP files #243

Closed aplatyps closed 1 year ago

aplatyps commented 1 year ago

When I was trying to test nerfacc by running python tests/test_grid.py, I ran into the following error: File "/.conda/envs/3dgen/lib/python3.8/site-packages/nerfacc/grid.py", line 43, in ray_aabb_intersect t_mins, t_maxs, hits = _C.ray_aabb_intersect( AttributeError: module 'nerfacc.cuda.csrc' has no attribute 'ray_aabb_intersect'

From what I understand, this means the cpp functions were not able to be imported to python. Therefore, I cloned the nerfacc repo to build the .o files linker so that python can import the functions defined in cpp.

@liruilong940607 sorry to bother you, but I've been trying to fix this whole day to no avail. When I was trying to build nerfacc via setup.py, I run into the following issue:

nvcc -Inerfacc/nerfacc/cuda/csrc/include -I.conda/envs/3dgen/lib/python3.8/site-packages/torch/include -I.conda/envs/3dgen/lib/python3.8/site-packages/torch/include/THC -I.conda/envs/3dgen/lib/python3.8/site-packages/torch/include/TH -I.conda/envs/3dgen/lib/python3.8/site-packages/torch/include/torch/csrc/api/include -I.conda/envs/3dgen/include -I.conda/envs/3dgen/include/python3.8 -c nerfacc/nerfacc/cuda/csrc/camera.cu -o nerfacc/build/temp.linux-x86_64-cpython-38/nerfacc/cuda/csrc/camera.o -DCUDA_NO_HALF_OPERATORS -DCUDA_NO_HALF_CONVERSIONS -DCUDA_NO_BFLOAT16_CONVERSIONS -DCUDA_NO_HALF2_OPERATORS --expt-relaxed-constexpr --compiler-options '-fPIC' -O3 --expt-relaxed-constexpr -DTORCH_API_INCLUDE_EXTENSION_H -DPYBIND11_COMPILER_TYPE=\"_gcc\" -DPYBIND11_STDLIB=\"_libstdcpp\" -DPYBIND11_BUILD_ABI=\"_cxxabi1011\" -DTORCH_EXTENSION_NAME=csrc -D_GLIBCXX_USE_CXX11_ABI=0 -gencode=arch=compute_75,code=compute_75 -gencode=arch=compute_75,code=sm_75 -std=c++14 /.conda/envs/3dgen/include/thrust/system/cuda/config.h(109): error: name must be a namespace name

1 error detected in the compilation of "nerfacc/nerfacc/cuda/csrc/camera.cu".

I checked all the .cu and .cuh files, they all have an empty namespace wrapping a namespace named device. I tried changing the namespace names and still getting the same error. Any clue how can I fix this? Many thanks.

I'm running on Debian, nvcc version 11.7, python 3.8, pytorch 1.13.1+cu117, tinycudann 1.7, cmake 3.26.1.

liruilong940607 commented 1 year ago

Have you tried installing the prebuilt wheel?

pip install nerfacc -f https://nerfacc-bucket.s3.us-west-2.amazonaws.com/whl/torch-1.13.0_cu117/nerfacc-0.5.3%2Bpt113cu117-cp38-cp38-linux_x86_64.whl
aplatyps commented 1 year ago

Yes I have, I initially installed the prebuilt wheel but I got an issue on

File "/.conda/envs/3dgen/lib/python3.8/site-packages/nerfacc/grid.py", line 43, in ray_aabb_intersect
t_mins, t_maxs, hits = _C.ray_aabb_intersect(
AttributeError: module 'nerfacc.cuda.csrc' has no attribute 'ray_aabb_intersect'
aplatyps commented 1 year ago

Turns out there was a line in the .conda/envs/3dgen/include/thrust/system/cuda/config.h file that sets the namespace to ::cub causing the code unable to be compiled. Now everything is working.

Anyhow, I also tried uninstalling and reinstall with nerfacc with the prebuilt wheel, it works already. Thank you!