Open cdcseacave opened 2 years ago
same issue happen to me, Debug build was almost fast. but release taking more that 5 hours and I'm still waiting
I am having this issue as well. Were any of you able to work around this? @irenji @cdcseacave FYI - I am using a VM running Ubuntu 20.04 - I have it set up with 12 GB of RAM. I am building opengv as part of a larger overall build process (maplab) and this particular build step is the culprit - all 106 other libraries build successfully. It slowly consumes all my RAM (all 12 GB in about 4 mins, while only building 2%).
Same issue here, any solution?
It seems to work fine on linux and osx, it seems that on windows the compiler runs out of resources. I experienced that on my machine and also on my attempt to add the CI on github actions https://github.com/alicevision/opengv/actions/runs/5165375471/job/13981189036#step:6:227
Maybe trying with precompiled headers?
Using the MinGW64 toolchain on Windows significantly speeds up the building process--it takes around 3 minutes on my machine. MinGW64 provides gcc, making the compilation process akin to a Linux environment.
In case it is helpful (and as a reference for myself in the future :)), below I add steps to get (py)opengv up and running.
[!WARNING]
There is a specific issue that needs to be solved first. OpenGV definesstruct timeval
andgettimeofday
for Windows systems since they are native only to UNIX-like systems. Since MinGW already provides these, conflicts can occur during the build process. To prevent this, we need to modify L33 in test/time_measurement.cpp and L37 in test/time_measurement.hpp to change in both:#ifdef WIN32
to
#if defined(WIN32) && !defined(__MINGW32__)
The build process should take ~3 mins and the resulting compiled libraries will be stored in the folder \path\to\opengv\build\lib
.
[!WARNING]
Since the Python extension isn't statically compiled, the compiled.pyd
module (e.g.pyopengv.cp310-win_amd64.pyd
) will rely on several MinGW.dll
files at runtime. Thus, before importingpyopengv
, we need to add the MinGW binaries directory to the DLL search path in Python. This can be done for for Python >= 3.8 as follows:import os with os.add_dll_directory("C:\\msys64\\mingw64\\bin"): import pyopengv
Alternatively, to automate this, we can move the
.pyd
module to a manually createdpyopengv
folder within thesite-packages
directory of our Python interpreter. Inside thispyopengv
folder, besides having the.pyd
file, we need to create a__init__.py
file that contains something like:import os from pathlib import Path # constant for MinGW64 directory path. MINGW64_PATH = Path("C:\\msys64\\mingw64\\bin") def import_pyopengv(): """Import pyopengv, with optional modification to DLL search path.""" try: # check if the MinGW64 directory exists if MINGW64_PATH.is_dir(): # augment .dll search path to include MinGW64's bin directory. with os.add_dll_directory(str(MINGW64_PATH)): from . import pyopengv else: from . import pyopengv return pyopengv except ImportError as e: raise ImportError(f"Failed to import pyopengv: {e}") import_pyopengv() # clean up the namespace. del os, Path, import_pyopengv, MINGW64_PATH
After this,
pyopengv
can be imported, from any directory, as follows:from pyopengv import pyopengv
P.S. @simogasp I think the previous process can be included in a GHA workflow by using the action from MSYS2. The following is untested, but I believe something like it should work:
name: CI
on: [push]
jobs:
build_opengv_on_windows:
runs-on: windows-latest
steps:
# ... other needed steps ...
- name: Checkout
uses: actions/checkout@v3
- name: Setup MSYS2 on Windows
uses: msys2/setup-msys2@v2
with:
update: true
msystem: 'MSYS'
install: >-
base-devel
mingw-w64-x86_64-toolchain
mingw-w64-x86_64-eigen3
mingw-w64-x86_64-ninja
mingw-w64-x86_64-cmake
- name: build OpenGV
shell: msys2 {0}
env:
MSYSTEM: MINGW64
run: |
mkdir build && cd build
cmake -G Ninja .. -DCMAKE_BUILD_TYPE=Release -DBUILD_TESTS=OFF -DBUILD_PYTHON=OFF && ninja
Sometimes it is even crashing the machine as it runs out of memory even though I have 32GB RAM. Most probably it is not particular to opengv but any library using heavy templates. Does anybody have any suggestion how to make it compile (not run OOM) or even speed up? Are there any flags I can use?