-
Hi all, I'm building a project depending on Pytorch. Pytorch requires linking against Minimum ReproductionSource:#include <torch/torch.h>
int main(int argc, char **argv) {
torch::Tensor tensor = torch::rand({2, 3});
return 0;
} Meson configuration:
When building with meson (ninja backend), I get:Expand logFound ninja-1.11.1 at /nix/store/sxdnfgd4708mzaa5b0zcn8agpysyhmzy-ninja-1.11.1/bin/ninja
Cleaning... 0 files.
[2/2] Linking target test-torch
FAILED: test-torch
g++ -o test-torch test-torch.p/test-torch.cpp.o -Wl,--as-needed -Wl,--no-undefined -Wl,--start-group /nix/store/lv1y9iidkx6yrz428q3z6n2vnri25azj-libtorch-2.0.0/lib/libc10.so /nix/store/lv1y9ii
dkx6yrz428q3z6n2vnri25azj-libtorch-2.0.0/lib/libtorch.so -Wl,--end-group
/nix/store/inq79dwl8sz1ygmfbgsmg77i5cwmdjpz-binutils-2.40/bin/ld: test-torch.p/test-torch.cpp.o: in function `at::rand(c10::ArrayRef<long>, c10::TensorOptions)':
/nix/store/08bb4gwfvg9s2iw7yswbs0mrxh8axsgz-libtorch-2.0.0-dev/include/ATen/ops/rand.h:115: undefined reference to `at::_ops::rand::call(c10::ArrayRef<c10::SymInt>, c10::optional<c10::ScalarTyp
e>, c10::optional<c10::Layout>, c10::optional<c10::Device>, c10::optional<bool>)'
/nix/store/inq79dwl8sz1ygmfbgsmg77i5cwmdjpz-binutils-2.40/bin/ld: test-torch.p/test-torch.cpp.o: in function `torch::autograd::AutogradMeta::AutogradMeta(c10::TensorImpl*, bool, torch::autograd
::Edge)':
/nix/store/08bb4gwfvg9s2iw7yswbs0mrxh8axsgz-libtorch-2.0.0-dev/include/torch/csrc/autograd/variable.h:294: undefined reference to `vtable for torch::autograd::AutogradMeta'
collect2: error: ld returned 1 exit status
ninja: build stopped: subcommand failed. |
Beta Was this translation helpful? Give feedback.
Answered by
ditsuke
Sep 18, 2023
Replies: 1 comment
-
Slapstick solution: torch = [dependency('Torch'), gpp.find_library('torch_cpu')] Overall this is a problem with Pytorch' shared libs not linking |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
ditsuke
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Slapstick solution:
Overall this is a problem with Pytorch' shared libs not linking
pytorch_cpu
(orcuda
) when they need to, as discussed on Matrix. Reference: mesonbuild.matrix.org