Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[colmap] Build error #30272

Closed
alvin-xu-5745 opened this issue Mar 18, 2023 · 49 comments · Fixed by #39244
Closed

[colmap] Build error #30272

alvin-xu-5745 opened this issue Mar 18, 2023 · 49 comments · Fixed by #39244
Assignees
Labels
category:port-bug The issue is with a library, which is something the port should already support

Comments

@alvin-xu-5745
Copy link

alvin-xu-5745 commented Mar 18, 2023

Host Environment

  • OS: x64 Windows
  • Compiler: MSVC 14.28.29910
  • vcpkg-tool version: 2023-03-14-105f7f7e8a5ea10dfac9874ff9d1a6bacba5f454
  • vcpkg-scripts version: ffe7360 2023-03-17 (18 hours ago)
  • CUDA: 11.3

To Reproduce

Steps to reproduce the behavior:

./vcpkg install colmap[cuda]:x64-windows

Failure logs
stdout-x64-windows.log

install-x64-windows-dbg-out.log

@alvin-xu-5745 alvin-xu-5745 added the category:port-bug The issue is with a library, which is something the port should already support label Mar 18, 2023
@JackBoosY
Copy link
Contributor

nvcc fatal   : A single input file is required for a non-link phase when an outputfile is specified

@alvin-xu-5745
Copy link
Author

Any ideas would could be causing that problem?

@Tobe2d
Copy link

Tobe2d commented Apr 12, 2023

@JonLiu1993 forward me here to help fixing my issue.

everything I try from those links give me similar error:

CMake Error at scripts/cmake/vcpkg_execute_build_process.cmake:134 (message):
    Command failed: "C:/Program Files/CMake/bin/cmake.exe" --build . --config Debug --target install -- -v -j33
    Working Directory: E:/Ai__Project/nerfstudio/vcpkg/buildtrees/colmap/x64-windows-dbg
    See logs for more information:
      E:\Ai__Project\nerfstudio\vcpkg\buildtrees\colmap\install-x64-windows-dbg-out.log

Call Stack (most recent call first):
  installed/x64-windows/share/vcpkg-cmake/vcpkg_cmake_build.cmake:74 (vcpkg_execute_build_process)
  installed/x64-windows/share/vcpkg-cmake/vcpkg_cmake_install.cmake:16 (vcpkg_cmake_build)
  ports/colmap/portfile.cmake:60 (vcpkg_cmake_install)
  scripts/ports.cmake:147 (include)


error: building colmap:x64-windows failed with: BUILD_FAILED
Please ensure you're using the latest port files with `git pull` and `vcpkg update`.
Then check for known issues at:
    https://github.com/microsoft/vcpkg/issues?q=is%3Aissue+is%3Aopen+in%3Atitle+colmap
You can submit a new issue at:
    https://github.com/microsoft/vcpkg/issues/new?title=[colmap]+Build+error&body=Copy+issue+body+from+E%3A%2FAi__Project%2Fnerfstudio%2Fvcpkg%2Finstalled%2Fvcpkg%2Fissue_body.md

Any help please?

I am on Windows 11
RTX 4090

@FrankXie05
Copy link
Contributor

@Tobe2d Paths with special characters may cause NVCC to interpret them as multiple files being passed in.
Mabye try to modify it to a standardized path and please provide the error log:
install-x64-windows-dbg-out.log

@Tobe2d
Copy link

Tobe2d commented Apr 12, 2023

Thanks @FrankXie05 for the reply,

Below is the log file:

install-x64-windows-dbg-out.log

@FrankXie05
Copy link
Contributor

@Tobe2d Could you please try replacing the colmap in your vcpkg\ports directory with mine? I made a patch.

It seems that the upstream did not include when using the macro COLMAP_ADD_CUDA_SOURCES to pass in the header file of cuda
https://github.com/colmap/colmap/blob/3.8/cmake/CMakeHelper.cmake#LL89C1-L107C34

colmap.zip

@Tobe2d
Copy link

Tobe2d commented Apr 13, 2023

Thanks @FrankXie05 I replaced the zip to colmap in vcpkg\ports
I test building colmap and again got this:

error: building colmap:x64-windows failed with: BUILD_FAILED
Please ensure you're using the latest port files with `git pull` and `vcpkg update`.
Then check for known issues at:
    https://github.com/microsoft/vcpkg/issues?q=is%3Aissue+is%3Aopen+in%3Atitle+colmap
You can submit a new issue at:
    https://github.com/microsoft/vcpkg/issues/new?title=[colmap]+Build+error&body=Copy+issue+body+from+E%3A%2FAi__Project%2Fnerfstudio%2Fvcpkg%2Finstalled%2Fvcpkg%2Fissue_body.md

@FrankXie05
Copy link
Contributor

Errror log?

@Tobe2d
Copy link

Tobe2d commented Apr 14, 2023

Failure logs

-- Using cached colmap-colmap-30da037ce19bdceb6d239c45342fadb221bdabb2.tar.gz.
-- Cleaning sources at E:/nerfstudio/vcpkg/buildtrees/colmap/src/b221bdabb2-a77d7326e5.clean. Use --editable to skip cleaning for the packages you specify.
-- Extracting source E:/nerfstudio/vcpkg/downloads/colmap-colmap-30da037ce19bdceb6d239c45342fadb221bdabb2.tar.gz
-- Applying patch fix-dependencies.patch
-- Applying patch fix-cuda-include.patch
-- Using source at E:/nerfstudio/vcpkg/buildtrees/colmap/src/b221bdabb2-a77d7326e5.clean
-- Found external ninja('1.11.0').
-- Configuring x64-windows-dbg
-- Configuring x64-windows-rel
-- Building x64-windows-dbg
CMake Error at scripts/cmake/vcpkg_execute_build_process.cmake:134 (message):
Command failed: "C:/Program Files/CMake/bin/cmake.exe" --build . --config Debug --target install -- -v -j33
Working Directory: E:/nerfstudio/vcpkg/buildtrees/colmap/x64-windows-dbg
See logs for more information:
E:\nerfstudio\vcpkg\buildtrees\colmap\install-x64-windows-dbg-out.log

Call Stack (most recent call first):
installed/x64-windows/share/vcpkg-cmake/vcpkg_cmake_build.cmake:74 (vcpkg_execute_build_process)
installed/x64-windows/share/vcpkg-cmake/vcpkg_cmake_install.cmake:16 (vcpkg_cmake_build)
ports/colmap/portfile.cmake:61 (vcpkg_cmake_install)
scripts/ports.cmake:147 (include)

@cheng-chi
Copy link

Hi @FrankXie05 I encountered similar issue and this is my error log after applying your colmap.zip patch to vcpkg/ports
install-x64-windows-dbg-out.log

@FrankXie05
Copy link
Contributor

I don't see an error in the log file you provided. Could you please provide the console output? @cheng-chi

@cheng-chi
Copy link

@FrankXie05 Thanks for the fast reply! The errors are buried a little deep here. You can find them by searchring for nvcc fatal in the file. One example error is:

FAILED: src/CMakeFiles/colmap_cuda.dir/mvs/gpu_mat_ref_image.cu.obj 
C:\PROGRA~1\NVIDIA~2\CUDA\v11.7\bin\nvcc.exe -forward-unknown-to-host-compiler -DBOOST_ALL_DYN_LINK=1 -DCGAL_ENABLED -DCGAL_USE_GMPXX=1 -DCUDA_ENABLED -DEIGEN_INITIALIZE_MATRICES_BY_NAN -DGFLAGS_IS_A_DLL=1 -DGLOG_NO_ABBREVIATED_SEVERITIES -DGL_GLEXT_PROTOTYPES -DGUI_ENABLED -DIMATH_DLL -DOPENEXR_DLL -DOPENGL_ENABLED -DOPENMP_ENABLED -DQT_CORE_LIB -DQT_GUI_LIB -DQT_OPENGL_LIB -DQT_WIDGETS_LIB -DWIN32_LEAN_AND_MEAN -D_MWAITXINTRIN_H_INCLUDED -IC:\Users\cchi\vcpkg\buildtrees\colmap\src\b221bdabb2-a77d7326e5.clean\lib -IC:\Users\cchi\vcpkg\buildtrees\colmap\src\b221bdabb2-a77d7326e5.clean\src -isystem=C:\Users\cchi\vcpkg\installed\x64-windows\include -isystem=C:\Users\cchi\vcpkg\installed\x64-windows\include\eigen3 -isystem=C:\Users\cchi\vcpkg\installed\x64-windows\include\qt5 -isystem=C:\Users\cchi\vcpkg\installed\x64-windows\include\qt5\QtCore -isystem=C:\Users\cchi\vcpkg\installed\x64-windows\tools\qt5\mkspecs\win32-msvc -isystem=C:\Users\cchi\vcpkg\installed\x64-windows\include\qt5\QtOpenGL -isystem=C:\Users\cchi\vcpkg\installed\x64-windows\include\qt5\QtWidgets -isystem=C:\Users\cchi\vcpkg\installed\x64-windows\include\qt5\QtGui -isystem="C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.7\include" -isystem=C:\Users\cchi\vcpkg\installed\x64-windows\include\webp -isystem=C:\Users\cchi\vcpkg\installed\x64-windows\include\OpenEXR -isystem=C:\Users\cchi\vcpkg\installed\x64-windows\include\Imath -isystem=C:\Users\cchi\vcpkg\installed\x64-windows\include\GKlib -D_WINDOWS -Xcompiler="/W3 /GR /EHsc" -D_FORCE_INLINES -Wno-deprecated-gpu-targets --use_fast_math --default-stream per-thread -Xptxas=-suppress-stack-size-warning -Xcompiler="-MDd  -Zi -Ob0 -Od /RTC1" -arch=native /EHsc -D_SCL_SECURE_NO_DEPRECATE -D_SCL_SECURE_NO_WARNINGS -std=c++14 -MD -MT src\CMakeFiles\colmap_cuda.dir\mvs\gpu_mat_ref_image.cu.obj -MF src\CMakeFiles\colmap_cuda.dir\mvs\gpu_mat_ref_image.cu.obj.d -x cu -c C:\Users\cchi\vcpkg\buildtrees\colmap\src\b221bdabb2-a77d7326e5.clean\src\mvs\gpu_mat_ref_image.cu -o src\CMakeFiles\colmap_cuda.dir\mvs\gpu_mat_ref_image.cu.obj -Xcompiler=-Fdsrc\CMakeFiles\colmap_cuda.dir\colmap_cuda.pdb,-FS
nvcc fatal   : A single input file is required for a non-link phase when an outputfile is specified

@cheng-chi
Copy link

@FrankXie05 Here's my console output:

./vcpkg install colmap[cuda]:x64-windows
Computing installation plan...
The following packages will be built and installed:
    colmap[core,cuda]:x64-windows -> 2023-03-12#2
Detecting compiler hash for triplet x64-windows...
Restored 0 package(s) from C:\Users\cchi\AppData\Local\vcpkg\archives in 95.3 us. Use --debug to see more details.
Installing 1/1 colmap:x64-windows...
Building colmap[core,cuda]:x64-windows...
-- Using cached colmap-colmap-30da037ce19bdceb6d239c45342fadb221bdabb2.tar.gz.
-- Cleaning sources at C:/Users/cchi/vcpkg/buildtrees/colmap/src/b221bdabb2-a77d7326e5.clean. Use --editable to skip cleaning for the packages you specify.
-- Extracting source C:/Users/cchi/vcpkg/downloads/colmap-colmap-30da037ce19bdceb6d239c45342fadb221bdabb2.tar.gz
-- Applying patch fix-dependencies.patch
-- Applying patch fix-cuda-include.patch
-- Using source at C:/Users/cchi/vcpkg/buildtrees/colmap/src/b221bdabb2-a77d7326e5.clean
-- Found external ninja('1.11.0').
-- Configuring x64-windows-dbg
-- Configuring x64-windows-rel
-- Building x64-windows-dbg
CMake Error at scripts/cmake/vcpkg_execute_build_process.cmake:134 (message):
    Command failed: C:/Users/cchi/vcpkg/downloads/tools/cmake-3.25.1-windows/cmake-3.25.1-windows-i386/bin/cmake.exe --build . --config Debug --target install -- -v -j25
    Working Directory: C:/Users/cchi/vcpkg/buildtrees/colmap/x64-windows-dbg
    See logs for more information:
      C:\Users\cchi\vcpkg\buildtrees\colmap\install-x64-windows-dbg-out.log

Call Stack (most recent call first):
  installed/x64-windows/share/vcpkg-cmake/vcpkg_cmake_build.cmake:74 (vcpkg_execute_build_process)
  installed/x64-windows/share/vcpkg-cmake/vcpkg_cmake_install.cmake:16 (vcpkg_cmake_build)
  ports/colmap/portfile.cmake:61 (vcpkg_cmake_install)
  scripts/ports.cmake:147 (include)


error: building colmap:x64-windows failed with: BUILD_FAILED
Please ensure you're using the latest port files with `git pull` and `vcpkg update`.
Then check for known issues at:
    https://github.com/microsoft/vcpkg/issues?q=is%3Aissue+is%3Aopen+in%3Atitle+colmap
You can submit a new issue at:
    https://github.com/microsoft/vcpkg/issues/new?title=[colmap]+Build+error&body=Copy+issue+body+from+C%3A%2FUsers%2Fcchi%2Fvcpkg%2Finstalled%2Fvcpkg%2Fissue_body.md

@FrankXie05
Copy link
Contributor

Could you please provide the file: C:\Users\cchi\vcpkg\buildtrees\colmap\config-x64-windows-dbg-out.log?

@cheng-chi
Copy link

cheng-chi commented Apr 17, 2023

@FrankXie05 Here you go! Unfortunately I don't have much experience with vcpkg and windows programming in general. Sorry for not providing all information upfront
config-x64-windows-dbg-out.log

@bjornpiltz
Copy link
Contributor

I ran in to this and the problem seems to be the stray /EHsc passed to nvcc (the unquoted one). If I remove it, I can get a single nvcc command to run.

I haven't been able to able to make the project to compile, though. Patching away this line didn't help.

@SharkWipf
Copy link

Issue is still present today. Following the steps to install nerfstudio on Windows, after compiling deps for over an hour, the COLMAP steps:

git clone https://github.com/microsoft/vcpkg
cd vcpkg
bootstrap-vcpkg.bat
vcpkg install colmap[cuda]:x64-windows

just fail with the same error. --head fails as well.
nvcc fatal : A single input file is required for a non-link phase when an outputfile is specified
CUDA toolkit 11.8.

install-x64-windows-dbg-out.log

@acse-pms122
Copy link

Hi, I have the same error here. Apparently it has something to do with VSCode and some spaces in the paths

@alexmgee
Copy link

Issue is still present today. Following the steps to install nerfstudio on Windows, after compiling deps for over an hour, the COLMAP steps:

git clone https://github.com/microsoft/vcpkg
cd vcpkg
bootstrap-vcpkg.bat
vcpkg install colmap[cuda]:x64-windows

just fail with the same error. --head fails as well. nvcc fatal : A single input file is required for a non-link phase when an outputfile is specified CUDA toolkit 11.8.

install-x64-windows-dbg-out.log

I am having this problem now also.

@alexmgee
Copy link

alexmgee commented Jul 6, 2023

I decided to run it on Linux instead.

I am a total Linux idiot but have set it up before on a virtual machine. Could I run nerfstudio from Linux within a virtual machine?

Would it be possible to install Linux on my machine and dual-boot between Windows 11 and Linux?

@SharkWipf
Copy link

I decided to run it on Linux instead.

I am a total Linux idiot but have set it up before on a virtual machine. Could I run nerfstudio from Linux within a virtual machine?

Would it be possible to install Linux on my machine and dual-boot between Windows 11 and Linux?

No, not easily, you need the video card for CUDA, which the VM doesn't get access to.
I'd suggest trying WSL2, which is like a Linux virtual machine integrated in Windows, with CUDA support.

@alexmgee
Copy link

alexmgee commented Jul 6, 2023

No, not easily, you need the video card for CUDA, which the VM doesn't get access to. I'd suggest trying WSL2, which is like a Linux virtual machine integrated in Windows, with CUDA support.

Thank you for the response, I appreciate all the help we can get on this issue. Is the dual-boot concept not an option either?

I will look into WSL2... haven't had time yet to try the above methods.

@SharkWipf
Copy link

SharkWipf commented Jul 6, 2023

Is the dual-boot concept not an option either?

Dual boot is perfectly fine, though keep in mind you'll have to pre-distribute your disk space between operating systems, and NeRFs can use up a lot of space pretty quickly. I'm up to 500GB on my NeRF folder already.

That said, this is getting pretty off-topic for this issue/repo, and does not lead to a fix for the actual issue, so it might be time to move this elsewhere. The Nerfstudio Discord is a better place for individual support.

@Randomblock1
Copy link

I was able to get nerfstudio working by installing both colmap and mpir from conda-forge. But building it manually from vcpkg still doesn't work.

@BinglunWang
Copy link

Issue is still present today. Following the steps to install nerfstudio on Windows, after compiling deps for over an hour, the COLMAP steps:

git clone https://github.com/microsoft/vcpkg
cd vcpkg
bootstrap-vcpkg.bat
vcpkg install colmap[cuda]:x64-windows

just fail with the same error. --head fails as well. nvcc fatal : A single input file is required for a non-link phase when an outputfile is specified CUDA toolkit 11.8.
install-x64-windows-dbg-out.log

I am having this problem now also.

Hi, have you solved this problem? I have the same log error as you. If yes, may I know how you solve it? Thank you so much in advance

@adrien-StGir
Copy link

adrien-StGir commented Aug 23, 2023 via email

@everydaydigital
Copy link

everydaydigital commented Sep 1, 2023

Hi there - after hours of downloading and building vcpkg on Windows 10 while trying to get nerfstudio to work, I had the same error message:

error: building colmap:x64-windows failed with: BUILD_FAILED

Thankfully, after a bit of tweaking and reading through this post and some other github comments, I was able to get nerfstudio to run smoothly across multiple hard drives, with the following steps. Your mileage may vary but hope these notes help -

  • Install MS VS community 2022 along with desktop development C++ toolkit. (Make sure to uninstall any other versions of VS and VS BuildTools - having multiple versions caused me so many headaches!)

  • Install CUDA 11.8 (make sure to include the Visual Studio Integration Component during CUDA install under Custom>CUDA>Visual Studio Integration)

  • Install CUDNN - download and extract the folder from within the zip to your desktop (this validates correct user file permissions) and then copy and replace all of the folders (bin, include & lib) from the extracted cudnn folder into the CUDA toolkit folder here, replacing all existing files/folders:
    C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.8

  • To be certain that the file paths were correct during installation, copy the 4 files from the CUDA toolkit extras folder:
    C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.8\extras\visual_studio_integration\MSBuildExtensions

  • Paste them into the VS plugins directory here, ensuring that the visual studio plugin is now definitely in the correct location:
    D:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\Microsoft\VC\v170\BuildCustomizations

  • Here I'm using 'D:\Code\nerf-studio\env' as both the name of the env and the storage path of the env files (this lets you choose an install drive other than the default C:).

  • By pointing your conda environment to this vcvarsall.bat file (quotes and all), you can run the cmake build process within the conda command prompt window.
    conda create --prefix D:\Code\nerf-studio\env -y python=3.8
    conda activate D:\Code\nerf-studio\env
    python -m pip install --upgrade pip
    pip install torch==2.0.1+cu118 torchvision==0.15.2+cu118 --extra-index-url https://download.pytorch.org/whl/cu118
    conda install -c "nvidia/label/cuda-11.8.0" cuda-toolkit
    cd\
    D:
    cd D:\Code\nerf-studio\
    git clone --recursive https://github.com/nvlabs/tiny-cuda-nn
    cd D:\Code\nerf-studio\tiny-cuda-nn
    "D:\Program Files\Microsoft Visual Studio\2022\Community\VC\Auxiliary\Build\vcvarsall.bat" x64
    cmake . -B build
    cmake --build build --config RelWithDebInfo -j
    cd D:\Code\nerf-studio\tiny-cuda-nn\bindings\torch
    python setup.py install
    pip install nerfstudio
    conda install -c conda-forge colmap
    conda install -c conda-forge mpir
    cd D:\Code\nerf-studio\videos

  • RUN THIS COMMAND to build the training data from 360 video [crop bottom 20% on 30s (3*30=90) video) :
    ns-process-data video --camera-type equirectangular --images-per-equirect 8 --num-frames-target 90 --crop-factor 0 0.2 0 0 --data D:\Code\nerf-studio\videos\input\test_360-video_50mbps_3840x1920_h.265_remove-grain.mp4 --output-dir D:\Code\nerf-studio\videos\output

  • or image:
    ns-process-data images --camera-type equirectangular --crop-factor 0 0.2 0 0 --data D:\Code\nerf-studio\images\input --output-dir D:\Code\nerf-studio\images\output

  • At this point, I was able visualize the data with either of these commands:
    ns-train nerfacto --data D:\Code\nerf-studio\videos\output
    ns-train nerfacto --data D:\Code\nerf-studio\images\output

  • This took about 1 hour to complete processing the NERF from a 30-second, 360 degree video from an Insta360 ONE X2 Camera using an i9-9700 CPU, with 32GB RAM and an NVIDIA RTX 3070 GPU with 8GB VRAM.

  • After that's done, you can view it again any time with this command:
    ns-viewer --load-config D:\Code\nerf-studio\videos\outputs\output\nerfacto\2023-09-01_155318\config.yml

  • Exporting a point cloud of the trained data was as easy as:
    ns-export pointcloud --load-config D:\Code\nerf-studio\videos\outputs\output\nerfacto\2023-09-01_155318\config.yml --output-dir D:\Code\nerf-studio\videos\exports\pcd\ --num-points 1000000 --remove-outliers True --normal-method open3d --use-bounding-box True --bounding-box-min -1 -1 -1 --bounding-box-max 1 1 1

@tfwittwer
Copy link

The build error is caused by the /EHsc argument in the nvcc command line. A manual workaround is to edit the build.ninja file and run ninja directly.

@SamuelJamesFisher
Copy link

Same issue, Have tried making sure there are no spaces in ANY paths. Cuda, vcpkg, visual studio all have no spaces in their paths.

C:\NVIDIAGPU
C:\Tool\vcpkg
C:\Tool\VisualStudio

Log.
install-x64-windows-dbg-out.log

@tfwittwer
Copy link

The issue is not with spaces, but with arguments with slashes - in this case the /EHsc command. This can be deleted from the ninja files. In one case I encountered it was possible to edit the build.ninja file, in other cases I had to edit the rules.ninja file and delete the $FLAGS argument in the nvcc calls.
Then run ninja from a Visual Studio Developer Prompt as shown on line 3 of your log.

@SamuelJamesFisher
Copy link

Still no luck tried both and a combination of the two. Taken from the Visual Studio Developer Prompt with the command: C:/Tool/VisualStudio/Common7/IDE/CommonExtensions/Microsoft/CMake/Ninja/ninja.exe -v -v -j17 install
All /EHsc commands were deleted from build.ninja and $FLAGS were deleted from rules .ninja where the exe was nvcc.exe

outputLogNoFlagsInNVCCCalls.txt
outputLogNoEHsc.txt
outputLogNoEHscAndNoFlags.txt

@tfwittwer
Copy link

Which version of Visual Studio and CUDA do you use? I haven't encountered those errors using the latest version of Visual Studio 2022 and CUDA 12.1.

@SamuelJamesFisher
Copy link

Visual studio 2019 per colmaps recomendation, cuda 12.2.
Have just tried visual studio 2022 latest version and 12.1 same errors.

@SamuelJamesFisher
Copy link

Just an update. I gave up on windows, installed a linux os on dual-boot, had colmap working in around an hour. I spent over a week trying to sort this error on windows.

@samr
Copy link

samr commented Nov 19, 2023

I ran in to this and the problem seems to be the stray /EHsc passed to nvcc (the unquoted one). If I remove it, I can get a single nvcc command to run.

I haven't been able to able to make the project to compile, though. Patching away this line didn't help.

I ran into the same exact behavior/issue, but adding the following hack that essentially "escapes" the extra \EHsc fixed it for me.

if(CUDA_ENABLED)
    COLMAP_ADD_LIBRARY(
        NAME colmap_mvs_cuda
        ...
    )
    # Hack for the extra \EHsc that gets added on Windows to the nvcc compile line, which causes the error:
    # "nvcc fatal: A single input file is required for a non-link phase when an outputfile is specified..."
    if(IS_MSVC)
        set_target_properties(colmap_mvs_cuda PROPERTIES COMPILE_OPTIONS -Xcompiler)
    endif()

@longhuan2018
Copy link
Contributor

longhuan2018 commented Nov 24, 2023

It works.

I ran in to this and the problem seems to be the stray passed to nvcc (the unquoted one). If I remove it, I can get a single nvcc command to run./EHsc
I haven't been able to able to make the project to compile, though. Patching away this line didn't help.

I ran into the same exact behavior/issue, but adding the following hack that essentially "escapes" the extra \EHsc fixed it for me.

if(CUDA_ENABLED)
    COLMAP_ADD_LIBRARY(
        NAME colmap_mvs_cuda
        ...
    )
    # Hack for the extra \EHsc that gets added on Windows to the nvcc compile line, which causes the error:
    # "nvcc fatal: A single input file is required for a non-link phase when an outputfile is specified..."
    if(IS_MSVC)
        set_target_properties(colmap_mvs_cuda PROPERTIES COMPILE_OPTIONS -Xcompiler)
    endif()

Create new file fix-cuda.patch

diff --git a/src/colmap/mvs/CMakeLists.txt b/src/colmap/mvs/CMakeLists.txt
index a15d3bb5c..952e1e56b 100644
--- a/src/colmap/mvs/CMakeLists.txt
+++ b/src/colmap/mvs/CMakeLists.txt
@@ -90,6 +90,12 @@ if(CUDA_ENABLED)
             CUDA::curand
     )
 
+    # Hack for the extra \EHsc that gets added on Windows to the nvcc compile line, which causes the error:
+    # "nvcc fatal: A single input file is required for a non-link phase when an outputfile is specified..."
+    if(IS_MSVC)
+        set_target_properties(colmap_mvs_cuda PROPERTIES COMPILE_OPTIONS -Xcompiler)
+    endif()
+
     COLMAP_ADD_TEST(
         NAME gpu_mat_test
         SRCS gpu_mat_test.cu

Modify ports/colmap/portfile.cmake

vcpkg_from_github(
    ......
    PATCHES
        fix-cuda.patch
)

@snoutmate
Copy link

For background info - this is caused by IMath and OpenEXR libraries (both dependencies of FreeImage which is dependency of colmap) declaring compile argument '/EHsc' in cmake as INTERFACE_COMPILE_OPTIONS, which is fine for C compiler, but not for CUDA(nvcc). The patch posted by longhuan2018 should work, it is also possible to replace the flag with conditional '$<$<NOT:$<COMPILE_LANGUAGE:CUDA>>:/EHsc>' so that it still applies to C targets.

Here is a patch for top level CMakeLists.txt i made before stumbling upon this thread:

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 00337e5..54d543f 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -251,6 +251,17 @@ set_target_properties(
     EXCLUDE_FROM_ALL 1
     EXCLUDE_FROM_DEFAULT_BUILD 1)
 
+# On Windows, libraries IMath and OpenEXR (both imported via FreeImage lib) 
+# declare parameter '/EHsc' in interface options properties. With CUDA enabled 
+# this however gets also passed to NVCC compiler as a commandline argument
+# causing compile errors, so we need to fix that.
+if(CUDA_ENABLED AND IS_MSVC)
+    foreach(tgt Imath::Imath OpenEXR::Iex OpenEXR::IlmThread OpenEXR::OpenEXRCore OpenEXR::OpenEXR OpenEXR::OpenEXRUtil)
+        get_property(iface_opts TARGET ${tgt} PROPERTY INTERFACE_COMPILE_OPTIONS)
+        string(REPLACE "/EHsc" "\$<\$<NOT:\$<COMPILE_LANGUAGE:CUDA>>:/EHsc>" new_iface_opts "${iface_opts}")
+        set_property(TARGET ${tgt} PROPERTY INTERFACE_COMPILE_OPTIONS ${new_iface_opts})
+    endforeach()
+endif()
     
 ################################################################################
 # Install and uninstall scripts

@TicoCh1
Copy link

TicoCh1 commented Feb 16, 2024

in case anyone's still attempting nerfstudio, i kinda made it work

  1. download a released zip version of colmap from git eg. https://github.com/colmap/colmap/releases/tag/3.9.1
  2. unzip the file, rename the folder as colmap and put it to C:\
  3. by now you should have C:\colmap\bin\colmap.exe
  4. copy everything in C:\colmap\lib to C:\Windows\System32
  5. go to system environment variables and put C:\colmap\bin in the Path
  6. restart
  7. try colmap in cmd, it should work now

@alikarami-CM
Copy link

Hi, I have the same error here. Apparently it has something to do with VSCode and some spaces in the paths

if so
how did you solve ??

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
category:port-bug The issue is with a library, which is something the port should already support
Projects
None yet
Development

Successfully merging a pull request may close this issue.