Hi all!
I’m trying to compile libTorch, but finding errors no matter how I build it.
This is on an M1 mac.
I’ve tried all the various recommend methods from the official docs, here:
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
Trying the first method:
python ../tools/build_libtorch.py
I get a bunch of undefined symbols error:
Undefined symbols for architecture arm64:
"_MTLCopyAllDevices", referenced from:
Undefined symbols for architecture arm64:
"_MTLCopyAllDevices", referenced from:
at::mps::MPSDevice::MPSDevice() in libtorch_cpu.a(MPSDevice.mm.o)
Undefined symbols for architecture arm64:
"_MTLCopyAllDevices", referenced from:
at::mps::MPSDevice::MPSDevice() in libtorch_cpu.a(MPSDevice.mm.o)
at::mps::MPSDevice::MPSDevice() in libtorch_cpu.a(MPSDevice.mm.o)
Guessing that maybe some subcomponent is compiling for x86_64 instead of arm? Maybe there is a flag necessary to force arm/M1 compilation?
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
Using either other method (CMAKE or Setup.py, both outlined in the docs) it seems to get further (92%) but then dies in a linking phase with a bunch of duplicate symbols errors like this:
**duplicate symbol 'at::native::DispatchStub<void (*)(at::TensorIteratorBase&, c10::Scalar const&), at::native::leaky_relu_backward_stub>::DEFAULT' in:
CMakeFiles/torch_cpu.dir/__/aten/src/ATen/native/cpu/Activation.cpp.DEFAULT.cpp.DEFAULT.cpp.o
CMakeFiles/torch_cpu.dir/__/aten/src/ATen/native/cpu/Activation.cpp.DEFAULT.cpp.o
**
Looking at those files, they both just include the “Activation.cpp”. Why exactly you would have 2 files both including some other file is not something I understand, so maybe someone else knows how to make sense of this?