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

Pip wheels for Mac M1 (arm64) #62

Closed
renatobusatto opened this issue Apr 29, 2022 · 10 comments
Closed

Pip wheels for Mac M1 (arm64) #62

renatobusatto opened this issue Apr 29, 2022 · 10 comments

Comments

@renatobusatto
Copy link

I am struggling to build the library on a Macbook Pro M1 with the given instructions and latest commit in master.

@sarlinpe
Copy link
Collaborator

sarlinpe commented Apr 29, 2022

I do not have access to a Macbook Pro M1, so I cannot help without detailed logs and error outputs. I do not know if anyone has tried so far. You likely need to build COLMAP and pycolmap from source - see colmap/colmap#1423

@renatobusatto
Copy link
Author

I finally managed to build on a MacBook Pro M1. I am not sure how I could contribute to this project, is it enough to share the .whl file?

@sarlinpe
Copy link
Collaborator

sarlinpe commented May 4, 2022

Can you please instead describe in details what steps you took to make it work so others can reproduce it?

@renatobusatto
Copy link
Author

I am using Homebrew and Miniforge.

First I had to install qt5 using Homebrew:
brew install qt5
And create a python 3.9 environment:
conda create -n myenv python=3.9
conda activate myenv

Then build Colmap:

conda install cmake boost eigen freeimage glog gflags metis suitesparse ceres-solver glew cgal
git clone -b dev git@github.com:colmap/colmap.git
cd colmap
mkdir build
cd build
cmake .. -DBOOST_STATIC=OFF -DQt5_DIR="/opt/homebrew/opt/qt@5/lib/cmake/Qt5" -DCGAL_DATA_DIR="/opt/homebrew/Caskroom/miniforge/base/myenv/hloc/lib/cmake/CGAL"
make
make install
sudo install_name_tool -add_rpath /opt/homebrew/Caskroom/miniforge/base/envs/myenv/lib /usr/local/bin/colmap
cd ../..
# Test with colmap -h

Then build pycolmap:

git clone --recursive git@github.com:colmap/pycolmap.git
cd pycolmap
export CMAKE_PREFIX_PATH="/opt/homebrew/opt/qt@5/lib/cmake/Qt5"
export CGAL_DATA_DIR="/opt/homebrew/Caskroom/miniforge/base/envs/myenv/lib/cmake/CGAL"
pip install -v .

@chekhovana
Copy link

I tried to build colmap following your steps. Everything went ok, but when I tried to start it, I got the following error:

ERROR: flag 'flagfile' was defined more than once (in files '/tmp/gflags-20211021-3963-1mi18ai/gflags-2.2.2/src/gflags.cc' and '/Users/runner/miniforge3/conda-bld/gflags_1599590635449/work/src/gflags.cc').

Could you guess what might be the problem?

@yliuiuc1990
Copy link

I was able to build, but got an error when trying to import pycomap:

>>> import pycolmap
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: dlopen(/PATH_TO_PYTHON/python3.9/site-packages/pycolmap.cpython-39-darwin.so, 0x0002): symbol not found in flat namespace '___kmpc_barrier'

Any idea what went wrong? I used the dev branch of colmap as of today (7/15/2022). Should I use a different version of colmap for ToT pycolmap?

@yliuiuc1990
Copy link

I was able to build, but got an error when trying to import pycomap:

>>> import pycolmap
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: dlopen(/PATH_TO_PYTHON/python3.9/site-packages/pycolmap.cpython-39-darwin.so, 0x0002): symbol not found in flat namespace '___kmpc_barrier'

Any idea what went wrong? I used the dev branch of colmap as of today (7/15/2022). Should I use a different version of colmap for ToT pycolmap?

I was able to resolve this error by disabling OpenMP, i.e. change the ON in this line of CMakeLIst.txt of colmap repo to OFF:

option(OPENMP_ENABLED "Whether to enable OpenMP parallelization" OFF)

Not sure about the performance penalty this incurs.

@CGCooke
Copy link

CGCooke commented Mar 27, 2023

(Apple M2)

I tried this, and I was able to successfully compile COLMAP.

However, I was unable to compile pycolmap.

I got the error "clang: error: no such file or directory: 'NOTFOUND'"

I am using Homebrew and Miniforge.

First I had to install qt5 using Homebrew: brew install qt5 And create a python 3.9 environment: conda create -n myenv python=3.9 conda activate myenv

Then build Colmap:

conda install cmake boost eigen freeimage glog gflags metis suitesparse ceres-solver glew cgal
git clone -b dev git@github.com:colmap/colmap.git
cd colmap
mkdir build
cd build
cmake .. -DBOOST_STATIC=OFF -DQt5_DIR="/opt/homebrew/opt/qt@5/lib/cmake/Qt5" -DCGAL_DATA_DIR="/opt/homebrew/Caskroom/miniforge/base/myenv/hloc/lib/cmake/CGAL"
make
make install
sudo install_name_tool -add_rpath /opt/homebrew/Caskroom/miniforge/base/envs/myenv/lib /usr/local/bin/colmap
cd ../..
# Test with colmap -h

Then build pycolmap:

git clone --recursive git@github.com:colmap/pycolmap.git
cd pycolmap
export CMAKE_PREFIX_PATH="/opt/homebrew/opt/qt@5/lib/cmake/Qt5"
export CGAL_DATA_DIR="/opt/homebrew/Caskroom/miniforge/base/envs/myenv/lib/cmake/CGAL"
pip install -v .

@siyanhu
Copy link

siyanhu commented Nov 26, 2023

I am using Homebrew and Miniforge.

First I had to install qt5 using Homebrew: brew install qt5 And create a python 3.9 environment: conda create -n myenv python=3.9 conda activate myenv

Then build Colmap:

conda install cmake boost eigen freeimage glog gflags metis suitesparse ceres-solver glew cgal
git clone -b dev git@github.com:colmap/colmap.git
cd colmap
mkdir build
cd build
cmake .. -DBOOST_STATIC=OFF -DQt5_DIR="/opt/homebrew/opt/qt@5/lib/cmake/Qt5" -DCGAL_DATA_DIR="/opt/homebrew/Caskroom/miniforge/base/myenv/hloc/lib/cmake/CGAL"
make
make install
sudo install_name_tool -add_rpath /opt/homebrew/Caskroom/miniforge/base/envs/myenv/lib /usr/local/bin/colmap
cd ../..
# Test with colmap -h

Then build pycolmap:

git clone --recursive git@github.com:colmap/pycolmap.git
cd pycolmap
export CMAKE_PREFIX_PATH="/opt/homebrew/opt/qt@5/lib/cmake/Qt5"
export CGAL_DATA_DIR="/opt/homebrew/Caskroom/miniforge/base/envs/myenv/lib/cmake/CGAL"
pip install -v .

There are some mark-ups here:
[1] CGAL_DATA_DIR should be the true cgal path under your miniforge dir path. For example mine is "Users/myname/miniforge3/envs/py309slam/include/CGAL".
[2] to add rpath I use /Users/myname/miniforge3/envs/py309slam/lib. Same as [1], it should be within your own miniforge dir.
[3] I removed all installed libraries before the above steps following the direction in https://apple.stackexchange.com/questions/198623/uninstall-all-programs-installed-by-homebrew.
[4] conda install Flann should be added.

@sarlinpe
Copy link
Collaborator

sarlinpe commented Jan 3, 2024

We now have wheels for macOS M1 - they will be published on PyPI in the next release (in a few days). See package/install-colmap-macos.sh for an example of how to build dependencies locally.

@sarlinpe sarlinpe closed this as completed Jan 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants