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

Issue building for MacOS #108

Open
fmammoli opened this issue Jun 24, 2024 · 4 comments
Open

Issue building for MacOS #108

fmammoli opened this issue Jun 24, 2024 · 4 comments

Comments

@fmammoli
Copy link

fmammoli commented Jun 24, 2024

Hi,

I am working on a MacOS with M3 Pro.
I am trying to build OpenSplat for MacOS but keep hitting an error while running.

cmake -DCMAKE_PREFIX_PATH=/Users/fmammoli/Developer/pythonprojs/libtorch/share/cmake/Torch -DGPU_RUNTIME=MPS .. && make -j$(sysctl -n hw.logicalcpu)

I get the error:

`
11 warnings generated.

[ 13%] Built target gsplat_metal
[ 18%] Linking CXX static library libgsplat.a
[ 18%] Built target gsplat
[ 22%] Linking CXX static library libgsplat_cpu.a
[ 22%] Built target gsplat_cpu
[ 31%] Building CXX object CMakeFiles/opensplat.dir/point_io.cpp.o
[ 31%] Building CXX object CMakeFiles/opensplat.dir/spherical_harmonics.cpp.o
[ 36%] Building CXX object CMakeFiles/opensplat.dir/nerfstudio.cpp.o
[ 40%] Building CXX object CMakeFiles/opensplat.dir/utils.cpp.o
[ 45%] Building CXX object CMakeFiles/opensplat.dir/project_gaussians.cpp.o
[ 50%] Building CXX object CMakeFiles/opensplat.dir/kdtree_tensor.cpp.o
[ 54%] Building CXX object CMakeFiles/opensplat.dir/model.cpp.o
[ 59%] Building CXX object CMakeFiles/opensplat.dir/opensplat.cpp.o
[ 63%] Building CXX object CMakeFiles/opensplat.dir/cv_utils.cpp.o
[ 72%] Building CXX object CMakeFiles/opensplat.dir/rasterize_gaussians.cpp.o
[ 72%] Building CXX object CMakeFiles/opensplat.dir/ssim.cpp.o
[ 77%] Building CXX object CMakeFiles/opensplat.dir/optim_scheduler.cpp.o
[ 81%] Building CXX object CMakeFiles/opensplat.dir/colmap.cpp.o
[ 86%] Building CXX object CMakeFiles/opensplat.dir/opensfm.cpp.o
[ 90%] Building CXX object CMakeFiles/opensplat.dir/input_data.cpp.o
[ 95%] Building CXX object CMakeFiles/opensplat.dir/tensor_math.cpp.o
[100%] Linking CXX executable opensplat
Undefined symbols for architecture arm64:
"c10::impl::cow::materialize_cow_storage(c10::StorageImpl&)", referenced from:
void* c10::TensorImpl::data_impl<void, c10::TensorImpl::mutable_data()::'lambda'()>(c10::TensorImpl::mutable_data()::'lambda'() const&) const in model.cpp.o
ld: symbol(s) not found for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[2]: *** [opensplat] Error 1
make[1]: *** [CMakeFiles/opensplat.dir/all] Error 2
make: *** [all] Error 2
`

I also tried running with the Pytorch path installed via Mamba and got the same error.
I managed to build by installing Pytorch via homebrew and using that path instead of libtorch path, but as I am new to python I am trying to keep my env under control the best I can.

What I am doing wrong?

@pfxuan
Copy link
Collaborator

pfxuan commented Jun 25, 2024

It seems like there is a problem on the homebrew version of pytorch. Can you directly download libtorch instead? like

cd OpenSplat
wget https://download.pytorch.org/libtorch/cpu/libtorch-macos-arm64-2.2.1.zip
unzip libtorch-macos-arm64-2.2.1.zip
cd build
cmake -DCMAKE_PREFIX_PATH=../libtorch -DGPU_RUNTIME=MPS .. 

@fmammoli
Copy link
Author

fmammoli commented Jun 25, 2024

Directly downloading libtorch actually works and the build is done successfully after make -j$(sysctl -n hw.logicalcpu).
But when running ./openSplat now I get the error:

dyld[6669]: Library not loaded: @rpath/libomp.dylib
  Referenced from: <DD14EDEC-57EB-38BD-98C1-58FACE69BBEC> /Users/fmammoli/Developer/pythonprojs/libtorch/lib/libtorch_cpu.dylib
  Reason: tried: '/Users/runner/work/pytorch/pytorch/pytorch/build/lib/libomp.dylib' (no such file), '/System/Volumes/Preboot/Cryptexes/OS/Users/runner/work/pytorch/pytorch/pytorch/build/lib/libomp.dylib' (no such file), '/Users/runner/work/_temp/anaconda/envs/wheel_py38/lib/libomp.dylib' (no such file), '/System/Volumes/Preboot/Cryptexes/OS/Users/runner/work/_temp/anaconda/envs/wheel_py38/lib/libomp.dylib' (no such file), '/Users/runner/work/pytorch/pytorch/pytorch/build/lib/libomp.dylib' (no such file), '/System/Volumes/Preboot/Cryptexes/OS/Users/runner/work/pytorch/pytorch/pytorch/build/lib/libomp.dylib' (no such file), '/Users/fmammoli/Developer/pythonprojs/libtorch/lib/libomp.dylib' (no such file), '/System/Volumes/Preboot/Cryptexes/OS/Users/fmammoli/Developer/pythonprojs/libtorch/lib/libomp.dylib' (no such file), '/opt/homebrew/lib/libomp.dylib' (no such file), '/System/Volumes/Preboot/Cryptexes/OS/opt/homebrew/lib/libomp.dylib' (no such file), '/Users/fmammoli/Developer/pythonprojs/libtorch/lib/libomp.dylib' (no such file), '/System/Volumes/Preboot/Cryptexes/OS/Users/fmammoli/Developer/pythonprojs/libtorch/lib/libomp.dylib' (no such file), '/opt/homebrew/lib/libomp.dylib' (no such file), '/System/Volumes/Preboot/Cryptexes/OS/opt/homebrew/lib/libomp.dylib' (no such file), '/usr/local/lib/libomp.dylib' (no such file), '/usr/lib/libomp.dylib' (no such file, not in dyld cache)
zsh: abort      ./opensplat

My libomp.dylib indeed is in none of these paths, I found it on /opt/homebrew/Cellar/libomp/18.1.8/lib/libomp.dylib

Is there a way to add this path?

@pfxuan
Copy link
Collaborator

pfxuan commented Jun 25, 2024

Maybe you can try this:

export DYLD_LIBRARY_PATH=$(brew --prefix libomp)/lib:$DYLD_LIBRARY_PATH

@fmammoli
Copy link
Author

Exporting the path didn't solve the issue, but creating a symlink did between the brew --prefix libomp path/lib/libomp.dylib and one of the suggested paths did.

I can now run the example datasets without error! Thanks!

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

2 participants