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

Does not work on Apple Silicon #440

Closed
zzeee opened this issue Jan 3, 2022 · 6 comments
Closed

Does not work on Apple Silicon #440

zzeee opened this issue Jan 3, 2022 · 6 comments

Comments

@zzeee
Copy link

zzeee commented Jan 3, 2022

1.I have PyTorch 1.10 that works natively on my M1 Mac
I've downloaded libtorch from the website
2. I've added tch = "0.6.1" to cargo.toml
and when run cargo build I see:

note: ld: warning: ignoring file /Users/andrey/prj/nntest/target/debug/build/torch-sys-3c7217b1a617897c/out/libtorch/libtorch/lib/libtorch.dylib, building for macOS-arm64 but attempting to link with file built for macOS-x86_64
ld: warning: ignoring file /Users/andrey/prj/nntest/target/debug/build/torch-sys-3c7217b1a617897c/out/libtorch/libtorch/lib/libtorch_cpu.dylib, building for macOS-arm64 but attempting to link with file built for macOS-x86_64
ld: warning: ignoring file /Users/andrey/prj/nntest/target/debug/build/torch-sys-3c7217b1a617897c/out/libtorch/libtorch/lib/libc10.dylib, building for macOS-arm64 but attempting to link with file built for macOS-x86_64
Undefined symbols for architecture arm64:
"c10::impl::ExcludeDispatchKeyGuard::~ExcludeDispatchKeyGuard()", referenced from:
at::AutoDispatchBelowADInplaceOrView::~AutoDispatchBelowADInplaceOrView() in libtorch_sys-2bfcaab8f2fcc6a6.rlib(torch_api.o)
"c10::impl::ExcludeDispatchKeyGuard::ExcludeDispatchKeyGuard(c10::DispatchKeySet)", referenced from:
at::AutoDispatchBelowADInplaceOrView::AutoDispatchBelowADInplaceOrView() in libtorch_sys-2bfcaab8f2fcc6a6.rlib(torch_api.o)
"at::_ops::zeros::call(c10::ArrayRef, c10::optionalc10::ScalarType, c10::optionalc10::Layout, c10::optionalc10::Device, c10::optional)", referenced from:
at::zeros(c10::ArrayRef, c10::TensorOptions) in libtorch_sys-2bfcaab8f2fcc6a6.rlib(torch_api.o)
"vtable for torch::autograd::AutogradMeta", referenced from:
torch::autograd::AutogradMeta::AutogradMeta(c10::TensorImpl*, bool, torch::autograd::Edge) in libtorch_sys-2bfcaab8f2fcc6a6.rlib(torch_api.o)
NOTE: a missing vtable usually means the first non-inline virtual member function has no definition.
"c10::AutogradMetaInterface::~AutogradMetaInterface()", referenced from:
torch::autograd::AutogradMeta::AutogradMeta(c10::TensorImpl*, bool, torch::autograd::Edge) in libtorch_sys-2bfcaab8f2fcc6a6.rlib(torch_api.o)
"caffe2::TypeMeta::typeMetaDatas()", referenced from:
caffe2::TypeMeta::data() const in libtorch_sys-2bfcaab8f2fcc6a6.rlib(torch_api.o)
"c10::TensorImpl::set_autograd_meta(std::__1::unique_ptr<c10::AutogradMetaInterface, std::__1::default_deletec10::AutogradMetaInterface >)", referenced from:
torch::autograd::make_variable(at::Tensor, bool, bool) in libtorch_sys-2bfcaab8f2fcc6a6.rlib(torch_api.o)
"c10::UndefinedTensorImpl::_singleton", referenced from:
c10::UndefinedTensorImpl::singleton() in libtorch_sys-2bfcaab8f2fcc6a6.rlib(torch_api.o)
"c10::detail::torchInternalAssertFail(char const*, char const*, unsigned int, char const*, std::__1::basic_string<char, std::__1::char_traits, std::__1::allocator > const&)", referenced from:
c10::Device::validate() in libtorch_sys-2bfcaab8f2fcc6a6.rlib(torch_api.o)
caffe2::TypeMeta::fromScalarType(c10::ScalarType) in libtorch_sys-2bfcaab8f2fcc6a6.rlib(torch_api.o)
"at::ops::mul_Scalar::call(at::Tensor const&, c10::Scalar const&)", referenced from:
at::mul(at::Tensor const&, c10::Scalar const&) in libtorch_sys-2bfcaab8f2fcc6a6.rlib(torch_api.o)
"c10::detail::torchInternalAssertFail(char const*, char const*, unsigned int, char const*, char const*)", referenced from:
c10::intrusive_ptr<c10::VariableVersion::VersionCounter, c10::detail::intrusive_target_default_null_typec10::VariableVersion::VersionCounter >::intrusive_ptr(c10::VariableVersion::VersionCounter*) in libtorch_sys-2bfcaab8f2fcc6a6.rlib(torch_api.o)
c10::intrusive_ptr_target::~intrusive_ptr_target() in libtorch_sys-2bfcaab8f2fcc6a6.rlib(torch_api.o)
c10::intrusive_ptr<c10::TensorImpl, c10::UndefinedTensorImpl>::retain
() in libtorch_sys-2bfcaab8f2fcc6a6.rlib(torch_api.o)
c10::ArrayRef::debugCheckNullptrInvariant() in libtorch_sys-2bfcaab8f2fcc6a6.rlib(torch_api.o)
"vtable for c10::AutogradMetaInterface", referenced from:
c10::AutogradMetaInterface::AutogradMetaInterface() in libtorch_sys-2bfcaab8f2fcc6a6.rlib(torch_api.o)
NOTE: a missing vtable usually means the first non-inline virtual member function has no definition.
"caffe2::TypeMeta::error_unsupported_typemeta(caffe2::TypeMeta)", referenced from:
caffe2::TypeMeta::toScalarType() in libtorch_sys-2bfcaab8f2fcc6a6.rlib(torch_api.o)
"c10::detail::torchCheckFail(char const*, char const*, unsigned int, char const*)", referenced from:
torch::autograd::AutogradMeta::AutogradMeta(c10::TensorImpl*, bool, torch::autograd::Edge) in libtorch_sys-2bfcaab8f2fcc6a6.rlib(torch_api.o)
c10::detail::torchInternalAssertFail(char const*, char const*, unsigned int, char const*, c10::detail::CompileTimeEmptyString) in libtorch_sys-2bfcaab8f2fcc6a6.rlib(torch_api.o)
c10::TensorImpl::itemsize() const in libtorch_sys-2bfcaab8f2fcc6a6.rlib(torch_api.o)
c10::TensorImpl::data() const in libtorch_sys-2bfcaab8f2fcc6a6.rlib(torch_api.o)
"at::print(std::__1::basic_ostream<char, std::__1::char_traits >&, at::Tensor const&, long long)", referenced from:
at::operator<<(std::__1::basic_ostream<char, std::__1::char_traits >&, at::Tensor const&) in libtorch_sys-2bfcaab8f2fcc6a6.rlib(torch_api.o)
ld: symbol(s) not found for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

@FVershinin
Copy link

Any news?

@l-monninger
Copy link

l-monninger commented May 24, 2022

This should tell you all you need to know: macOS-arm64 but attempting to link with file built for macOS-x86_64.

I don't think this an issue with this library at all, apart from a shortage of documentation. You simply don't have the right LibTorch build installed. How to do that, I don't know (#488).

@l-monninger
Copy link

@zzeee Btw, in the meantime, if you just want to experiment with the library, you should be able to run in Docker.

@zzeee
Copy link
Author

zzeee commented May 24, 2022

I just wanted to have experiments 5 months ago :) Now I use Pytorch because I can not wait for such a long time :)

@kodieg
Copy link

kodieg commented Jul 6, 2022

I managed to install pytorch from pip and set LIBTORCH variable and DYLD_LIBRARY_PATH accordingly.

pip install pytorch
export LIBTORCH=/Users/<username>/opt/miniconda3/lib//python3.9/site-packages/torch/
export DYLD_LIBRARY_PATH=${LIBTORCH}/lib:$DYLD_LIBRARY_PAT

Note, I used miniconda, so your library path may differ.

@LaurentMazare
Copy link
Owner

Closing in favor of #488

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

5 participants