NVlabs / instant-ngp

Instant neural graphics primitives: lightning fast NeRF and more
https://nvlabs.github.io/instant-ngp
Other
15.78k stars 1.9k forks source link

Error when compiling : tiny-cuda-nn and error MSB3721 #194

Closed gregbeast closed 2 years ago

gregbeast commented 2 years ago

Hi community,

the last step "cmake --build build --config RelWithDebInfo -j 16" generate some errors. All steps before seems good.

`tiny-cuda-nn\src\fully_fused_mlp.cu(416): error : name followed by "::" must be a class or namespace nam e [C:\AI\TinyCuda\tiny-cuda-nn\build\src\tiny-cuda-nn.vcxproj]

C:\AI\TinyCuda\tiny-cuda-nn\src\fully_fused_mlp.cu(496): error : name followed by "::" must be a class or namespace nam e [C:\AI\TinyCuda\tiny-cuda-nn\build\src\tiny-cuda-nn.vcxproj]

C:\AI\TinyCuda\tiny-cuda-nn\src\fully_fused_mlp.cu(496): error : name followed by "::" must be a class or namespace nam e [C:\AI\TinyCuda\tiny-cuda-nn\build\src\tiny-cuda-nn.vcxproj]

C:\AI\TinyCuda\tiny-cuda-nn\include\tiny-cuda-nn/encodings/grid.h(249): error : no operator "+=" matches these operands [C:\AI\TinyCuda\tiny-cuda-nn\build\src\tiny-cuda-nn.vcxproj]

:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Microsoft\VC\v160\BuildCustomizations\CUDA 11.6.t argets(790,9): error MSB3721: The command ""C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.6\bin\nvcc.exe" -gen code=arch=compute_52,code=\"sm_52,compute_52\" --use-local-env -ccbin "C:\Program Files (x86)\Microsoft Visual Studio\2 019\Community\VC\Tools\MSVC\14.29.30133\bin\HostX64\x64" -x cu -I"C:\AI\TinyCuda\tiny-cuda-nn\include" -I"C:\AI\TinyC uda\tiny-cuda-nn\dependencies" -I"C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.6\include" --keep-dir x64\ RelWithDebInfo -maxrregcount=0 --machine 64 --compile -cudart static --extended-lambda --expt-relaxed-constexpr -std= c++14 -Xcompiler="/EHsc -Zi -Ob1" -D_WINDOWS -DNDEBUG -DTCNN_MIN_GPU_ARCH=86 -DTCNN_SHAMPOO -D"CMAKE_INTDIR=\"RelWith DebInfo\"" -D_MBCS -D"CMAKE_INTDIR=\"RelWithDebInfo\"" -Xcompiler "/EHsc /W1 /nologo /O2 /FdC:\AI\TinyCuda\tiny-cuda-nn \build\src\RelWithDebInfo\tiny-cuda-nn.pdb /FS /Zi /MD /GR" -o tiny-cuda-nn.dir\RelWithDebInfo\cutlass_mlp.obj "C:\AI\ TinyCuda\tiny-cuda-nn\src\cutlass_mlp.cu"" exited with code 1. [C:\AI\TinyCuda\tiny-cuda-nn\build\src\tiny-cuda-nn.vcxp roj]`

My environment: ThreadRipper 3970 X GeForce RTX 3090 Win10 Cuda 11.6 Cmake 3.23 Visual Studio 2019 updated OptiX 7.4 Pyhton 3.9

Let me know if you know this issue and feel free to share tips,

vBitreel commented 2 years ago

I am having this issue as well and my environment is exactly identical to yours.

Tom94 commented 2 years ago

It looks like CMake generated sm_52,compute_52 nvcc arguments despite having detected your GPU architecture correctly (-DTCNN_MIN_GPU_ARCH=86). This is puzzling to me and shouldn't happen -- the correct arch arguments would be sm_86,compute_86.

Unfortunately, everything seems to be working fine my machine on the latest CMake, CUDA, and VS 2019, so I can't easily look for a fix.

Shot in the dark: perhaps hardcoding the appropriate flags

list(APPEND CUDA_NVCC_FLAGS "-gencode=arch=compute_86,code=\"sm_86,compute_86\"")

near the top of instant-ngp/CMakeLists.txt and instant-ngp/dependencies/tiny-cuda-nn/CMakeLists.txt will fix it on your systems.

vBitreel commented 2 years ago

Thank you, hardcoding the flags seems to work!

If anyone like me finds themselves wondering how to escape the quotes correctly, I ended up using: list(APPEND CUDA_NVCC_FLAGS "-gencode=arch=compute_86,code=\"sm_86,compute_86\"")

gregbeast commented 2 years ago

I confirm! Works like a charm. Thank you!

braveness23 commented 2 years ago

I'm using a GeForce RTX 4000 and setting it to

list(APPEND CUDA_NVCC_FLAGS "-gencode=arch=compute_75,code=\"sm_75,compute_75\"")

worked for me!