nerfstudio-project / nerfacc

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

Build failed with PyTorch <= 1.10 #112

Closed bennyguo closed 1 year ago

bennyguo commented 1 year ago

Could not build nerfacc cuda kernels with older PyTorch versions (<= 1.10). Error message:

nerfacc/cuda/csrc/include/helpers_cuda.h:10:10: fatal error: ATen/cuda/cub_definitions.cuh: No such file or directory
   10 | #include <ATen/cuda/cub_definitions.cuh>
      |          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
compilation terminated.

It seems that ATen/cuda/cub_definitions.cuh only exists after PyTorch 1.11. Maybe we should alter helper functions based on the PyTorch version.

liruilong940607 commented 1 year ago

Thanks Yuancheng for reporting! I will look into it soon

YaroslavShchekaturov commented 1 year ago

Hi there! I have the same issues !

kecol commented 1 year ago

Meanwhile, if you are working with pytorch < 1.11 you could try by editing the file nerfacc/cuda/csrc/include/helpers_cuda.h

Replace this line #include <ATen/cuda/cub_definitions.cuh>

With this block

//#include <ATen/cuda/cub_definitions.cuh>

// cub support for UniqueByKey is added to cub 1.16 in:
// https://github.com/NVIDIA/cub/pull/405
#if CUB_VERSION >= 101600
#define CUB_SUPPORTS_UNIQUE_BY_KEY() true
#else
#define CUB_SUPPORTS_UNIQUE_BY_KEY() false
#endif

// cub support for scan by key is added to cub 1.15
// in https://github.com/NVIDIA/cub/pull/376
#if CUB_VERSION >= 101500
#define CUB_SUPPORTS_SCAN_BY_KEY() 1
#else
#define CUB_SUPPORTS_SCAN_BY_KEY() 0
#endif

// cub support for cub::FutureValue is added to cub 1.15 in:
// https://github.com/NVIDIA/cub/pull/305
#if CUB_VERSION >= 101500
#define CUB_SUPPORTS_FUTURE_VALUE() true
#else
#define CUB_SUPPORTS_FUTURE_VALUE() false
#endif

PS: Doing the above I was able to run nerfacc using python 3.8 with this pytorch setup

pip install torch==1.10.1+cu111 torchvision==0.11.2+cu111 torchaudio==0.10.1 -f https://download.pytorch.org/whl/torch_stable.html
liruilong940607 commented 1 year ago

fixed now!