NVlabs / instant-ngp

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

identifier "TCNN _MIN_GPU_ARCH" is undefined on Windows #54

Closed o0Helloworld0o closed 2 years ago

o0Helloworld0o commented 2 years ago

Hi, I tried to build the project on my Win10 PC. However, the second command "cmake --build build --config RelWithDebInfo -j 16" raised errors.

Windows10 CUDA 11.1 RTX 3080 vs2019 cmake 3.22.1 MSVC 19.28.29921.0

【error info】 E:\GitHub_Space\instant-ngp\dependencies\tiny-cuda-nn\include\tiny-cuda-nn/common.h(50): error : identifier "TCNN _MIN_GPU_ARCH" is undefined [E:\chenxi\GitHub_Space\instant_01\build\optix_program.vcxproj]

E:\GitHub_Space\instant-ngp\dependencies\tiny-cuda-nn\include\tiny-cuda-nn/common.h(50): error : identifier "TCNN _MIN_GPU_ARCH" is undefined [E:\chenxi\GitHub_Space\instant_01\build\optix_program.vcxproj]

E:\GitHub_Space\instant-ngp\dependencies\tiny-cuda-nn\include\tiny-cuda-nn/common.h(50): error : identifier "TCNN _MIN_GPU_ARCH" is undefined [E:\chenxi\GitHub_Space\instant_01\build\optix_program.vcxproj]

1 error detected in the compilation of "E:/GitHub_Space/instant_ngp/src/optix/raystab.cu". raystab.cu

Tom94 commented 2 years ago

Hi there, this error suggests your submodules are out of date.

Whenever pulling the latest version of this codebase, make sure to also update your submodules via

git submodule sync --recursive
git submodule update --recursive

Please feel free to re-open this issue if the above doesn't fix your problem!

Batlad commented 2 years ago

Hi I'm having the same problem and and tried the submodule sync/updates with no change in behaviour

windows10 CUDA 11.3 RTX 3090 visual studio 15 cmake 3.22.1 MSVC 19.16.27045.0

I had to use the below addition to cmake get it to compile in 64 bit mode to support OptiX cmake . -B build -G "Visual Studio 15 Win64"

But when running cmake --build build --config RelWithDebInfo -j 16 I get three errors downstream from identifier "TCNN_MIN_GPU_ARCH" is undefined The errors are in: raystab.cu pathescape.cu raytrace.cu

Also I needed to use conda install -c conda-forge openexr

Since both the requirements.txt approach gave and error for openEXR, and the prebuilt openEXR .whl files would not work on my system.

Tom94 commented 2 years ago

Strange. I just pushed an attempted fix -- could you pull and try again?

Batlad commented 2 years ago

No change as far as I can tell. I'll try again in a fresh environment.

is there a way to check that I've pulled the latest version from the command line?

Tom94 commented 2 years ago

Pertaining to your error, you could look for

If both are present, your submodules & main repo should both be good. To troubleshoot further: which GPU architecture does CMake detect? You can see this in the log as

Targeting GPU architectures: XX
Batlad commented 2 years ago

Fresh environment gives the same errors and previously reported.

copied from my fresh files 192 add_definitions(${TCNN_DEFINITIONS})

120 set(TCNN_DEFINITIONS ${TCNN_DEFINITIONS} PARENT_SCOPE)

Targeting GPU architectures: 86

Which sounds right given I'm on a 3090

Tom94 commented 2 years ago

The only difference I can see to my local setup & CI is you're using VS 15 (2017) whereas I'm on VS 16 (2019), which I have doubts about being the culprit... but wouldn't rule out completely.

Could you double-check that ${TCNN_DEFINITIONS} contains the definition we are missing by adding a

message(STATUS "tcnn definitions: ${TCNN_DEFINITIONS}")

to the cmake script right above line 243, where it's set for the optix program? (target_compile_definitions(optix_program PUBLIC ${TCNN_DEFINITIONS}))

Batlad commented 2 years ago

Is this the relevant output?

-- Targeting GPU architectures: 86
-- tcnn definitions: -DTCNN_MIN_GPU_ARCH=86;-DTCNN_SHAMPOO
-- Configuring done
-- Generating done
-- Build files have been written to: C:/Work/NGP/instant-ngp/build
Microsoft (R) Build Engine version 15.9.21+g9802d43bc3 for .NET Framework
Copyright (C) Microsoft Corporation. All rights reserved.
Batlad commented 2 years ago

In case it's relevant here's the rest of the output. I'll look into updating Visual Studio just in case. I'll also note the warning CMP0127 in case that's relevant as well.

(NGP2) C:\Work\NGP\instant-ngp>cmake --build build --config RelWithDebInfo -j 16
CMake is re-running because C:/Work/NGP/instant-ngp/build/CMakeFiles/generate.stamp is out-of-date.
  the file 'C:/Work/NGP/instant-ngp/CMakeLists.txt'
  is newer than 'C:/Work/NGP/instant-ngp/build/CMakeFiles/generate.stamp.depend'
  result='-1'
-- Selecting Windows SDK version 10.0.16299.0 to target Windows 10.0.19041.
-- Using Win32 for window creation
-- OptiX_INSTALL_DIR value: C:\ProgramData\NVIDIA Corporation\OptiX SDK 7.4.0
-- pybind11 v2.7.1
CMake Warning (dev) at C:/Program Files/CMake/share/cmake-3.22/Modules/CMakeDependentOption.cmake:84 (message):
  Policy CMP0127 is not set: cmake_dependent_option() supports full Condition
  Syntax.  Run "cmake --help-policy CMP0127" for policy details.  Use the
  cmake_policy command to set the policy and suppress this warning.
Call Stack (most recent call first):
  dependencies/pybind11/CMakeLists.txt:98 (cmake_dependent_option)
This warning is for project developers.  Use -Wno-dev to suppress it.

  glfw_objects.vcxproj -> C:\Work\NGP\instant-ngp\build\dependencies\glfw\src\glfw_objects.dir\R
  elWithDebInfo\glfw_objects.lib
  Compiling CUDA source file ..\src\optix\raystab.cu...
  Compiling CUDA source file ..\src\optix\pathescape.cu...
  Compiling CUDA source file ..\src\optix\raytrace.cu...

C:\Work\NGP\instant-ngp\dependencies\tiny-cuda-nn\include\tiny-cuda-nn/common.h(50): error : ide
ntifier "TCNN_MIN_GPU_ARCH" is undefined [C:\Work\NGP\instant-ngp\build\optix_program.vcxproj]

C:\Work\NGP\instant-ngp\dependencies\tiny-cuda-nn\include\tiny-cuda-nn/common.h(50): error : ide
ntifier "TCNN_MIN_GPU_ARCH" is undefined [C:\Work\NGP\instant-ngp\build\optix_program.vcxproj]

C:\Work\NGP\instant-ngp\dependencies\tiny-cuda-nn\include\tiny-cuda-nn/common.h(50): error : ide
ntifier "TCNN_MIN_GPU_ARCH" is undefined [C:\Work\NGP\instant-ngp\build\optix_program.vcxproj]

  1 error detected in the compilation of "C:/Work/NGP/instant-ngp/src/optix/raystab.cu".
  raystab.cu
C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\Common7\IDE\VC\VCTargets\BuildCust
omizations\CUDA 11.3.targets(785,9): error MSB3721: The command ""C:\Program Files\NVIDIA GPU Co
mputing Toolkit\CUDA\v11.3\bin\nvcc.exe" -gencode=arch=compute_52,code=\"sm_52,compute_52\" --us
e-local-env -ccbin "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\
14.16.27023\bin\HostX86\x64" -x cu   -I"C:\Work\NGP\instant-ngp\dependencies" -I"C:\Work\NGP\ins
tant-ngp\dependencies\eigen" -I"C:\Work\NGP\instant-ngp\dependencies\filesystem" -I"C:\Work\NGP\
instant-ngp\dependencies\glfw\include" -I"C:\Work\NGP\instant-ngp\dependencies\imgui\gl3w" -I"C:
\Work\NGP\instant-ngp\dependencies\nanovdb" -I"C:\ProgramData\NVIDIA Corporation\OptiX SDK 7.4.0
\include" -I"C:\Work\NGP\instant-ngp\dependencies\tiny-cuda-nn\include" -I"C:\Work\NGP\instant-n
gp\dependencies\tiny-cuda-nn\dependencies" -I"C:\Work\NGP\instant-ngp\dependencies\tinylogger" -
I"C:\Work\NGP\instant-ngp\include" -I"C:\Work\NGP\instant-ngp\build" -I"C:\Program Files\NVIDIA
GPU Computing Toolkit\CUDA\v11.3\include"     --keep-dir x64\RelWithDebInfo  -maxrregcount=0  --
machine 64 -ptx -cudart static --expt-relaxed-constexpr -std=c++14 -Xcompiler="/EHsc -Zi -Ob1" -
o optix_program.dir\RelWithDebInfo\raystab.ptx "C:\Work\NGP\instant-ngp\src\optix\raystab.cu"" e
xited with code 1. [C:\Work\NGP\instant-ngp\build\optix_program.vcxproj]
  1 error detected in the compilation of "C:/Work/NGP/instant-ngp/src/optix/raytrace.cu".
  raytrace.cu
C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\Common7\IDE\VC\VCTargets\BuildCust
omizations\CUDA 11.3.targets(785,9): error MSB3721: The command ""C:\Program Files\NVIDIA GPU Co
mputing Toolkit\CUDA\v11.3\bin\nvcc.exe" -gencode=arch=compute_52,code=\"sm_52,compute_52\" --us
e-local-env -ccbin "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\
14.16.27023\bin\HostX86\x64" -x cu   -I"C:\Work\NGP\instant-ngp\dependencies" -I"C:\Work\NGP\ins
tant-ngp\dependencies\eigen" -I"C:\Work\NGP\instant-ngp\dependencies\filesystem" -I"C:\Work\NGP\
instant-ngp\dependencies\glfw\include" -I"C:\Work\NGP\instant-ngp\dependencies\imgui\gl3w" -I"C:
\Work\NGP\instant-ngp\dependencies\nanovdb" -I"C:\ProgramData\NVIDIA Corporation\OptiX SDK 7.4.0
\include" -I"C:\Work\NGP\instant-ngp\dependencies\tiny-cuda-nn\include" -I"C:\Work\NGP\instant-n
gp\dependencies\tiny-cuda-nn\dependencies" -I"C:\Work\NGP\instant-ngp\dependencies\tinylogger" -
I"C:\Work\NGP\instant-ngp\include" -I"C:\Work\NGP\instant-ngp\build" -I"C:\Program Files\NVIDIA
GPU Computing Toolkit\CUDA\v11.3\include"     --keep-dir x64\RelWithDebInfo  -maxrregcount=0  --
machine 64 -ptx -cudart static --expt-relaxed-constexpr -std=c++14 -Xcompiler="/EHsc -Zi -Ob1" -
o optix_program.dir\RelWithDebInfo\raytrace.ptx "C:\Work\NGP\instant-ngp\src\optix\raytrace.cu""
 exited with code 1. [C:\Work\NGP\instant-ngp\build\optix_program.vcxproj]
  1 error detected in the compilation of "C:/Work/NGP/instant-ngp/src/optix/pathescape.cu".
  pathescape.cu
C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\Common7\IDE\VC\VCTargets\BuildCust
omizations\CUDA 11.3.targets(785,9): error MSB3721: The command ""C:\Program Files\NVIDIA GPU Co
mputing Toolkit\CUDA\v11.3\bin\nvcc.exe" -gencode=arch=compute_52,code=\"sm_52,compute_52\" --us
e-local-env -ccbin "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\
14.16.27023\bin\HostX86\x64" -x cu   -I"C:\Work\NGP\instant-ngp\dependencies" -I"C:\Work\NGP\ins
tant-ngp\dependencies\eigen" -I"C:\Work\NGP\instant-ngp\dependencies\filesystem" -I"C:\Work\NGP\
instant-ngp\dependencies\glfw\include" -I"C:\Work\NGP\instant-ngp\dependencies\imgui\gl3w" -I"C:
\Work\NGP\instant-ngp\dependencies\nanovdb" -I"C:\ProgramData\NVIDIA Corporation\OptiX SDK 7.4.0
\include" -I"C:\Work\NGP\instant-ngp\dependencies\tiny-cuda-nn\include" -I"C:\Work\NGP\instant-n
gp\dependencies\tiny-cuda-nn\dependencies" -I"C:\Work\NGP\instant-ngp\dependencies\tinylogger" -
I"C:\Work\NGP\instant-ngp\include" -I"C:\Work\NGP\instant-ngp\build" -I"C:\Program Files\NVIDIA
GPU Computing Toolkit\CUDA\v11.3\include"     --keep-dir x64\RelWithDebInfo  -maxrregcount=0  --
machine 64 -ptx -cudart static --expt-relaxed-constexpr -std=c++14 -Xcompiler="/EHsc -Zi -Ob1" -
o optix_program.dir\RelWithDebInfo\pathescape.ptx "C:\Work\NGP\instant-ngp\src\optix\pathescape.
cu"" exited with code 1. [C:\Work\NGP\instant-ngp\build\optix_program.vcxproj]
Tom94 commented 2 years ago

I have to admit that I have no idea why CMake doesn't forward -DTCNN_MIN_GPU_ARCH=86, which appears to be correctly set, to the PTX compiler commands as the above logs are showing.

Maybe someone with more intimate knowledge of CMake/CUDA/PTX interplay can chime in?

Batlad commented 2 years ago

Thanks for your help, it is hugely appreciated. Almost done installing VS2019 and updating 2017 I'll let you know how that goes.

Batlad commented 2 years ago

I ended up just moving over to CUDA 11.6 (still on VS2017) and those errors disappeared. Hopefully it's all roses from here on out.

Batlad commented 2 years ago

It's all working now.

Thanks again for your help.

Would you consider adding the below line to the doc as an alternative to the prebuild openEXR wheels

If you have conda installed you can also use conda install -c conda-forge openexr

Also for folks with VS2017 the below may be useful

If you are using VS2017/15 you may need to use the below command to ensure 64 bit compilation cmake . -B build -G "Visual Studio 15 Win64"

I guess although installing CUDA 11.6 worked, that's not necessary the root of the problem.