Hi everyone, congratulations on the Apple Silicon and MPS support on Torch v1.12!
Are there any plans to also provide precompiled LibTorch for Apple Silicon
on the Installation page? We are using the C++ version of the libraries and for now the only way to automate installation is by downloading the wheel file and extracting the precompiled artifacts.
However, given the precompiled artifacts are already built for wheels, maybe they could also be made available on the website?
It would be nice to have pre-built binaries on the official installation page!
FWIW I have set up a small repository with M1 builds here:
GitHub - mlverse/libtorch-mac-m1: LibTorch builds for the M1 Macs .
I will use builds in this repository for the R bindings while we don’t have official builds available.
Any plans to build 1.12.1 as well?
Thanks! The wheel version also included libomp (or so it seems), but I have to install it manually with the precompiled version. Do you think this is something worth including too?
Yes, it seems they manually do this in setup.py:
This file has been truncated.
# Copy libiomp5.dylib inside the wheel package on OS X
lib_dir = os.path.join(self.build_lib, 'torch', 'lib')
libtorch_cpu_path = os.path.join(lib_dir, 'libtorch_cpu.dylib')
if not os.path.exists(libtorch_cpu_path):
# Parse libtorch_cpu load commands
otool_cmds = subprocess.check_output(['otool', '-l', libtorch_cpu_path]).decode('utf-8').split('\n')
rpaths, libs = , 
for idx, line in enumerate(otool_cmds):
if line.strip() == 'cmd LC_LOAD_DYLIB':
lib_name = otool_cmds[idx + 2].strip()
assert lib_name.startswith('name ')
libs.append(lib_name.split(' ', 1).rsplit('(', 1)[:-1])
if line.strip() == 'cmd LC_RPATH':
rpath = otool_cmds[idx + 2].strip()
assert rpath.startswith('path ')
rpaths.append(rpath.split(' ', 1).rsplit('(', 1)[:-1])
We can probably do the same in our builds.
Actually it seems it only embeds openMP in the x86_64 builds, because in this case it’s embedding libiomp5.dylib (the Intel OpenMP version).
I think we could still copy libomp.dylib to the lib directory though, but not sure what kind of problems that could cause.
Interesting. I can find “libiomp5.dylib” in the Apple arm64 wheel too, so if this is straightforward to add, it would be very helpful.
Makes sense! I just added a copy of libomp.dylib to the archive.
Excellent, it works. Thank you!