NVIDIA / gvdb-voxels

Sparse volume compute and rendering on NVIDIA GPUs
Other
672 stars 144 forks source link

cannot open file 'CUDA.lib' #109

Closed capslpop closed 3 years ago

capslpop commented 3 years ago

`LINK Pass 1: command "C:\PROGRA~2\MICROS~2\2019\COMMUN~1\VC\Tools\MSVC\1426~1.288\bin\Hostx64\x64\link.exe /nologo gRenderKernel\CMakeFiles\gRenderKernel.dir\mainrenderkernel.cpp.obj gRenderKernel\CMakeFiles\gRenderKernel.dir_\sample_utils\filepng.cpp.obj gRenderKernel\CMakeFiles\gRenderKernel.dir_\sample_utils\glew.c.obj /out:gRenderKernel\gRenderKernel.exe /implib:gRenderKernel\gRenderKernel.lib /pdb:gRenderKernel\gRenderKernel.pdb /version:0.0 /machine:x64 /debug /INCREMENTAL /subsystem:console gvdb_library\gvdb.lib opengl32.lib glu32.lib cuda.lib kernel32.lib user32.lib gdi32.lib winspool.lib shell32.lib ole32.lib oleaut32.lib uuid.lib comdlg32.lib advapi32.lib /MANIFEST /MANIFESTFILE:gRenderKernel\CMakeFiles\gRenderKernel.dir/intermediate.manifest gRenderKernel\CMakeFiles\gRenderKernel.dir/manifest.res" failed (exit code 1104) with the following output: C:\Users\johnw\Downloads\gvdb-voxels-master\gvdb-voxels-master\out\build\x64-Debug (default)\LINK : fatal error LNK1104: cannot open file 'cuda.lib' [6/19] Building CXX object gResample\CMakeFiles\gResample.dir\main_resample.cpp.obj ninja: build stopped: subcommand failed.

Build All failed.`

When I hit the build all option in CMake this is what I get. I was able to run all the binaries solutions including the ones with Optix. So far I have cuda 11.1, optix, cmake(visual studios 2019), and I am trying to run this on a rtx 2060.

looking a bit deeper into the problem it looks like Cmake is having a hard time with target_link_libraries(gvdb PUBLIC cuda.lib) in gvdb_library->CmakeList.txt. I have tried redownloading Cuda 11.1 and Cuda 10.2 but to no avail.

NBickford-NV commented 3 years ago

Hmm - CUDA 11.1 + OptiX + Visual Studio 2019 is one of the platforms we test on, so this is definitely an issue! It sounds like somehow CMake is finding the CUDA include directory at C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.1\include, but not including the directory at C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.1\lib\x64 to the linker. By any chance, did you get any interesting messages during CMake configuration (or if you delete the cache and re-configure the CMake project) - especially at the top, where CMake says where it found CUDA paths?

Thanks!

capslpop commented 3 years ago

I know for sure I have re-configured the project many times. I have not been able to find anything strange in the Cmake build. However, this is what I get as the full build of the project:

------ Build All started: Project: gvdb-voxels-master, Configuration: x64-Debug ------ [0/1] Re-running CMake... -- --> Find Sample Utils -- Using OpenGL -- Using PNG -- Using TGA -- Using GLEW -- Using NVGUI -- --> Using Sample Utils. C:/Users/johnw/Downloads/gvdb-voxels-master/gvdb-voxels-master/source/sample_utils

-- --> Find Sample Utils -- Using OpenGL -- Using PNG -- Using TGA -- Using GLEW -- Using NVGUI -- --> Using Sample Utils. C:/Users/johnw/Downloads/gvdb-voxels-master/gvdb-voxels-master/source/sample_utils

-- --> Find Sample Utils -- Using OpenGL -- Using PNG -- Using TGA -- Using GLEW -- Using NVGUI -- --> Using Sample Utils. C:/Users/johnw/Downloads/gvdb-voxels-master/gvdb-voxels-master/source/sample_utils

-- --> Find Sample Utils -- Using OpenGL -- Using PNG -- Using GLEW -- --> Using Sample Utils. C:/Users/johnw/Downloads/gvdb-voxels-master/gvdb-voxels-master/source/sample_utils

-- --> Find Sample Utils -- Using OpenGL -- Using PNG -- Using GLEW -- --> Using Sample Utils. C:/Users/johnw/Downloads/gvdb-voxels-master/gvdb-voxels-master/source/sample_utils

-- --> Find Sample Utils -- Using OpenGL -- Using PNG -- Using TGA -- Using GLEW -- Using NVGUI -- --> Using Sample Utils. C:/Users/johnw/Downloads/gvdb-voxels-master/gvdb-voxels-master/source/sample_utils

-- --> Find Sample Utils -- Using OpenGL -- Using PNG -- Using TGA -- Using GLEW -- Using NVGUI -- --> Using Sample Utils. C:/Users/johnw/Downloads/gvdb-voxels-master/gvdb-voxels-master/source/sample_utils

-- Configuring done -- Generating done -- Build files have been written to: C:/Users/johnw/Downloads/gvdb-voxels-master/gvdb-voxels-master/out/build/x64-Debug [1/37] Building CXX object gvdb_library\CMakeFiles\gvdb.dir\dummy.cpp.obj [2/37] Linking CXX shared library gvdblibrary\gvdb.dll [3/37] Building C object gInteractiveGL\CMakeFiles\gInteractiveGL.dir_\sampleutils\glew.c.obj [4/37] Building C object g3DPrint\CMakeFiles\g3DPrint.dir_\sampleutils\glew.c.obj [5/37] Building CXX object g3DPrint\CMakeFiles\g3DPrint.dir_\sample_utils\nvgui.cpp.obj [6/37] Building CXX object gInteractiveGL\CMakeFiles\gInteractiveGL.dir_\sample_utils\nvgui.cpp.obj [7/37] Building CXX object gInteractiveGL\CMakeFiles\gInteractiveGL.dir_\sample_utils\mainwin.cpp.obj [8/37] Building CXX object g3DPrint\CMakeFiles\g3DPrint.dir_\sample_utils\mainwin.cpp.obj [9/37] Building CXX object gInteractiveGL\CMakeFiles\gInteractiveGL.dir_\sample_utils\filetga.cpp.obj [10/37] Building CXX object g3DPrint\CMakeFiles\g3DPrint.dir_\sample_utils\filepng.cpp.obj [11/37] Building CXX object gInteractiveGL\CMakeFiles\gInteractiveGL.dir_\sample_utils\file_png.cpp.obj [12/37] Linking CXX executable gDepthMap\gDepthMap.exe FAILED: gDepthMap/gDepthMap.exe cmd.exe /C "cd . && "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\Common7\IDE\CommonExtensions\Microsoft\CMake\CMake\bin\cmake.exe" -E vs_link_exe --intdir=gDepthMap\CMakeFiles\gDepthMap.dir --rc=C:\PROGRA~2\WI3CF2~1\10\bin\100183~1.0\x64\rc.exe --mt=C:\PROGRA~2\WI3CF2~1\10\bin\100183~1.0\x64\mt.exe --manifests -- C:\PROGRA~2\MICROS~2\2019\COMMUN~1\VC\Tools\MSVC\1426~1.288\bin\Hostx64\x64\link.exe /nologo gDepthMap\CMakeFiles\gDepthMap.dir\maindepthmap.cpp.obj gDepthMap\CMakeFiles\gDepthMap.dir_\sample_utils\filepng.cpp.obj gDepthMap\CMakeFiles\gDepthMap.dir_\sample_utils\filetga.cpp.obj gDepthMap\CMakeFiles\gDepthMap.dir_\sampleutils\glew.c.obj gDepthMap\CMakeFiles\gDepthMap.dir_\sample_utils\mainwin.cpp.obj gDepthMap\CMakeFiles\gDepthMap.dir_\sample_utils\nv_gui.cpp.obj /out:gDepthMap\gDepthMap.exe /implib:gDepthMap\gDepthMap.lib /pdb:gDepthMap\gDepthMap.pdb /version:0.0 /machine:x64 /debug /INCREMENTAL /subsystem:console gvdb_library\gvdb.lib opengl32.lib glu32.lib cuda.lib kernel32.lib user32.lib gdi32.lib winspool.lib shell32.lib ole32.lib oleaut32.lib uuid.lib comdlg32.lib advapi32.lib && cd ." LINK Pass 1: command "C:\PROGRA~2\MICROS~2\2019\COMMUN~1\VC\Tools\MSVC\1426~1.288\bin\Hostx64\x64\link.exe /nologo gDepthMap\CMakeFiles\gDepthMap.dir\maindepthmap.cpp.obj gDepthMap\CMakeFiles\gDepthMap.dir_\sample_utils\filepng.cpp.obj gDepthMap\CMakeFiles\gDepthMap.dir_\sample_utils\filetga.cpp.obj gDepthMap\CMakeFiles\gDepthMap.dir_\sampleutils\glew.c.obj gDepthMap\CMakeFiles\gDepthMap.dir_\sample_utils\mainwin.cpp.obj gDepthMap\CMakeFiles\gDepthMap.dir_\sample_utils\nv_gui.cpp.obj /out:gDepthMap\gDepthMap.exe /implib:gDepthMap\gDepthMap.lib /pdb:gDepthMap\gDepthMap.pdb /version:0.0 /machine:x64 /debug /INCREMENTAL /subsystem:console gvdb_library\gvdb.lib opengl32.lib glu32.lib cuda.lib kernel32.lib user32.lib gdi32.lib winspool.lib shell32.lib ole32.lib oleaut32.lib uuid.lib comdlg32.lib advapi32.lib /MANIFEST /MANIFESTFILE:gDepthMap\CMakeFiles\gDepthMap.dir/intermediate.manifest gDepthMap\CMakeFiles\gDepthMap.dir/manifest.res" failed (exit code 1104) with the following output: C:\Users\johnw\Downloads\gvdb-voxels-master\gvdb-voxels-master\out\build\x64-Debug\LINK : fatal error LNK1104: cannot open file 'cuda.lib' [13/37] Linking CXX executable gRenderKernel\gRenderKernel.exe FAILED: gRenderKernel/gRenderKernel.exe cmd.exe /C "cd . && "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\Common7\IDE\CommonExtensions\Microsoft\CMake\CMake\bin\cmake.exe" -E vs_link_exe --intdir=gRenderKernel\CMakeFiles\gRenderKernel.dir --rc=C:\PROGRA~2\WI3CF2~1\10\bin\100183~1.0\x64\rc.exe --mt=C:\PROGRA~2\WI3CF2~1\10\bin\100183~1.0\x64\mt.exe --manifests -- C:\PROGRA~2\MICROS~2\2019\COMMUN~1\VC\Tools\MSVC\1426~1.288\bin\Hostx64\x64\link.exe /nologo gRenderKernel\CMakeFiles\gRenderKernel.dir\mainrenderkernel.cpp.obj gRenderKernel\CMakeFiles\gRenderKernel.dir_\sample_utils\filepng.cpp.obj gRenderKernel\CMakeFiles\gRenderKernel.dir_\sample_utils\glew.c.obj /out:gRenderKernel\gRenderKernel.exe /implib:gRenderKernel\gRenderKernel.lib /pdb:gRenderKernel\gRenderKernel.pdb /version:0.0 /machine:x64 /debug /INCREMENTAL /subsystem:console gvdb_library\gvdb.lib opengl32.lib glu32.lib cuda.lib kernel32.lib user32.lib gdi32.lib winspool.lib shell32.lib ole32.lib oleaut32.lib uuid.lib comdlg32.lib advapi32.lib && cd ." LINK Pass 1: command "C:\PROGRA~2\MICROS~2\2019\COMMUN~1\VC\Tools\MSVC\1426~1.288\bin\Hostx64\x64\link.exe /nologo gRenderKernel\CMakeFiles\gRenderKernel.dir\mainrenderkernel.cpp.obj gRenderKernel\CMakeFiles\gRenderKernel.dir_\sample_utils\filepng.cpp.obj gRenderKernel\CMakeFiles\gRenderKernel.dir_\sample_utils\glew.c.obj /out:gRenderKernel\gRenderKernel.exe /implib:gRenderKernel\gRenderKernel.lib /pdb:gRenderKernel\gRenderKernel.pdb /version:0.0 /machine:x64 /debug /INCREMENTAL /subsystem:console gvdblibrary\gvdb.lib opengl32.lib glu32.lib cuda.lib kernel32.lib user32.lib gdi32.lib winspool.lib shell32.lib ole32.lib oleaut32.lib uuid.lib comdlg32.lib advapi32.lib /MANIFEST /MANIFESTFILE:gRenderKernel\CMakeFiles\gRenderKernel.dir/intermediate.manifest gRenderKernel\CMakeFiles\gRenderKernel.dir/manifest.res" failed (exit code 1104) with the following output: C:\Users\johnw\Downloads\gvdb-voxels-master\gvdb-voxels-master\out\build\x64-Debug\LINK : fatal error LNK1104: cannot open file 'cuda.lib' [14/37] Building CXX object g3DPrint\CMakeFiles\g3DPrint.dir_\sample_utils\file_tga.cpp.obj [15/37] Building CXX object gRenderToFile\CMakeFiles\gRenderToFile.dir\main_rendertofile.cpp.obj [16/37] Building CXX object gInteractiveGL\CMakeFiles\gInteractiveGL.dir\main_interactive_gl.cpp.obj [17/37] Building CXX object g3DPrint\CMakeFiles\g3DPrint.dir\main_3dprint.cpp.obj ninja: build stopped: subcommand failed.

Build All failed.

capslpop commented 3 years ago

I just tried deleting all the cash and re-building it. I got this 'The CUDA compiler identification is NVIDIA 11.1.105' along with ncvv linking properly. Which seems very normal. I also got this notice 'host_defines.h is an internal header file and must not be used directly. This file will be removed in a future CUDA release. Please use cuda_runtime_api.h or cuda_runtime.h instead.'.

NBickford-NV commented 3 years ago

Ah, so is the linker error fixed now?

Looks like the host_defines.h warning was coming from a radix sort file which we no longer use (we use Thrust instead) - so it should be fixed now if one pulls the latest code!

capslpop commented 3 years ago

Hmm, I just downloaded the latest code and tried compiling it but I still got the same linking error: cannot open file 'cuda.lib'

NBickford-NV commented 3 years ago

OK, I managed to reproduce the issue! The key is that you're building using Ninja, instead of from within Visual Studio. Ninja can't find the directory containing cuda.lib for some reason, which is why it failed. (I reproduced this by using the x64 Native Tools Command Prompt for VS 2019 along with cmake -GNinja.)

I think I've just fixed this by adding some code in gvdb_library's CMakeLists.txt to get the absolute path to cuda.lib, which seems to make it work for Ninja!

I don't know enough about Ninja to know why adding the x64 lib path to the user's PATH doesn't seem to help Ninja here, or why this works in Visual Studio but not in Ninja, but let me know if this fixed it!

capslpop commented 3 years ago

Yes, it works! Thank you so much! I have been scratching my head on this issue for a while now. It is very satisfying to see the build succeeded! Thanks again!