Doing builds on m1 macs

Does anyone have a guide for this? I need to do a rebuild of pytorch and libtorch to use the la pack for a model I’m trying to move to mobile. Does anyone have any guides or experience that would help me with this?

cc @xta0 - do you have some pointers how to make this work?

@Matt_Davis so far I don’t have experience in building PyTorch on M1 Mac. I did some web search and find some folks successfully built it on M1.

Hi Matt,

What I run is:
OPENSSL_ROOT_DIR="/opt/homebrew/opt/openssl/" BLAS=“Generic” MACOSX_DEPLOYMENT_TARGET=10.9 CC=clang CXX=clang++ python setup.py install

Possible BLAS option: “Generic” (which uses cblas), “OpenBLAS”, “vecLib”

You may need to add other env variables depending on what you have in your env - generally a sane homebrew python install should get you there eventually

An update MACOSX_DEPLOYMENT_TARGET=10.9 does not work any more as you now get errors related to this target being too low:

In file included from /Users/davidradley/pytorch/aten/src/ATen/native/mkl/SpectralOps.cpp:206:

**/Users/davidradley/pytorch/third_party/pocketfft/pocketfft_hdronly.h:156:15:** **error:** **'aligned_alloc' is only available on macOS 10.15 or newer [-Werror,-Wunguarded-availability-new]**

void *ptr = ::aligned_alloc(align,(size+align-1)&(~(align-1)));

**^~~~~~~~~~~~~~~**

**/Library/Developer/CommandLineTools/SDKs/MacOSX13.3.sdk/usr/include/malloc/_malloc.h:50:10: note:** 'aligned_alloc' has been marked as being introduced in macOS 10.15 here, but the deployment target is macOS 10.9.0

void *aligned_alloc(size_t __alignment, size_t __size) __result_use_check __alloc_size(2) __OSX_AVAILABLE(10.15) __IOS_AVAILABLE(13.0) __TVOS_AVAILABLE(13.0) __WATCHOS_AVAILABLE(6.0);

**^**

**/Users/davidradley/pytorch/third_party/pocketfft/pocketfft_hdronly.h:156:15: note:** enclose 'aligned_alloc' in a __builtin_available check to silence this warning

void *ptr = ::aligned_alloc(align,(size+align-1)&(~(align-1)));

Perhaps try disabling PocketFFT if possible, via AT_POCKETFFT_ENABLED CMake option?