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

How to run caffe in the M1 mac? I meet a problem. #7019

Open
shadowwu1 opened this issue Sep 21, 2021 · 10 comments
Open

How to run caffe in the M1 mac? I meet a problem. #7019

shadowwu1 opened this issue Sep 21, 2021 · 10 comments

Comments

@shadowwu1
Copy link

I use the homebrew in M1 mac to install the lib such as boost, hdm5. After I change the cmakelist and cmake successed , I try to run make, but I meet problem below:

Undefined symbols for architecture arm64:
"boost::python::detail::init_module(char const*, void (*)())", referenced from:
_init_caffe in _caffe.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]: *** [lib/_caffe.dylib] Error 1
make[1]: *** [python/CMakeFiles/pycaffe.dir/all] Error 2
make: *** [all] Error 2

when i install boost by homebrew, it look like boost supoort arm64, I try to find some solution or some problom just like I meet, but I thought I was the first one who try to use this simple solution to run caffe in the M1 mac which is arm core inside rather than x86. I hope someone can give me some help to make it. Thanks!
This is my Cmakelist file.
CMakeLists.txt

@klrc
Copy link

klrc commented Oct 20, 2021

same problem, the only solution for me now is using docker

@rverma-dev
Copy link

@klrc can you give reference on how you solved with docker?
Thanks

@xxlyu-2046
Copy link

应该是库没链接对,我试过M1可以跑

@klrc
Copy link

klrc commented Jan 20, 2022

@klrc can you give reference on how you solved with docker? Thanks

solved now, pls make sure to link with your arm64 python library
I edit CMakeCache.txt like this:

//Path to a library.
PYTHON_LIBRARY:FILEPATH=/opt/homebrew/Cellar/python@3.9/3.9.10/Frameworks/Python.framework/Versions/3.9/lib/libpython3.9.dylib

hope this helps

you can also check this:
https://www.dazhuanlan.com/evenlemon/topics/947293

NOTE: pycaffe cannot run through Rosetta (e.g. anaconda) because of x86_64 arch

@wym11ciri
Copy link

@klrc can you give reference on how you solved with docker? Thanks

solved now, pls make sure to link with your arm64 python library I edit CMakeCache.txt like this:

//Path to a library.
PYTHON_LIBRARY:FILEPATH=/opt/homebrew/Cellar/python@3.9/3.9.10/Frameworks/Python.framework/Versions/3.9/lib/libpython3.9.dylib

hope this helps

you can also check this: https://www.dazhuanlan.com/evenlemon/topics/947293

NOTE: pycaffe cannot run through Rosetta (e.g. anaconda) because of x86_64 arch

Can you show me your whole cmakecache.txt? I modified it according to your method, but it still doesn't work. thank you

@xiaolin1990
Copy link

xiaolin1990 commented Feb 11, 2022 via email

@lovie123
Copy link

lovie123 commented Feb 11, 2022 via email

@dragonQian
Copy link

dragonQian commented Feb 11, 2022 via email

@wym11ciri
Copy link

I use the homebrew in M1 mac to install the lib such as boost, hdm5. After I change the cmakelist and cmake successed , I try to run make, but I meet problem below:

Undefined symbols for architecture arm64: "boost::python::detail::init_module(char const*, void (*)())", referenced from: _init_caffe in _caffe.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]: *** [lib/_caffe.dylib] Error 1 make[1]: *** [python/CMakeFiles/pycaffe.dir/all] Error 2 make: *** [all] Error 2

when i install boost by homebrew, it look like boost supoort arm64, I try to find some solution or some problom just like I meet, but I thought I was the first one who try to use this simple solution to run caffe in the M1 mac which is arm core inside rather than x86. I hope someone can give me some help to make it. Thanks! This is my Cmakelist file. CMakeLists.txt

您好请问解决了吗

@SLiang-liao
Copy link

SLiang-liao commented Jan 28, 2024

I got a problem, an the compile is terminated! the outputs are:

`

[ 75%] Building CXX object src/caffe/CMakeFiles/caffe.dir/util/db_lmdb.cpp.o
[ 75%] Building CXX object src/caffe/CMakeFiles/caffe.dir/util/hdf5.cpp.o
[ 76%] Building CXX object src/caffe/CMakeFiles/caffe.dir/util/im2col.cpp.o
[ 76%] Building CXX object src/caffe/CMakeFiles/caffe.dir/util/insert_splits.cpp.o
[ 78%] Building CXX object src/caffe/CMakeFiles/caffe.dir/util/io.cpp.o
[ 78%] Building CXX object src/caffe/CMakeFiles/caffe.dir/util/math_functions.cpp.o
[ 79%] Building CXX object src/caffe/CMakeFiles/caffe.dir/util/signal_handler.cpp.o
[ 79%] Building CXX object src/caffe/CMakeFiles/caffe.dir/util/upgrade_proto.cpp.o
[ 81%] Linking CXX shared library ../../lib/libcaffe.dylib
Undefined symbols for architecture arm64:
"_AbslInternalSpinLockWake_lts_20240116", referenced from:
absl::lts_20240116::base_internal::SpinLockWake(std::__1::atomic, bool) in libprotobuf.a(text_format.cc.o)
absl::lts_20240116::base_internal::SpinLockWake(std::__1::atomic
, bool) in libprotobuf.a(reflection_ops.cc.o)
absl::lts_20240116::base_internal::SpinLockWake(std::__1::atomic, bool) in libprotobuf.a(generated_message_reflection.cc.o)
absl::lts_20240116::base_internal::SpinLockWake(std::__1::atomic
, bool) in libprotobuf.a(descriptor.cc.o)
absl::lts_20240116::base_internal::SpinLockWake(std::__1::atomic, bool) in libprotobuf.a(message.cc.o)
absl::lts_20240116::base_internal::SpinLockWake(std::__1::atomic
, bool) in libprotobuf.a(dynamic_message.cc.o)
absl::lts_20240116::base_internal::SpinLockWake(std::__1::atomic, bool) in libprotobuf.a(wire_format.cc.o)
...
"utf8_range::IsStructurallyValid(absl::lts_20240116::string_view)", referenced from:
google::protobuf::internal::WireFormatLite::VerifyUtf8String(char const
, int, google::protobuf::internal::WireFormatLite::Operation, char const*) in libprotobuf.a(wire_format_lite.cc.o)

`

how can i solve it?

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

9 participants