Skip to content

Cross compile TorchVision for Apple M1 #5171

@malfet

Description

@malfet

🚀 The feature

PyTorch cross-compiles nightly binaries for M1 for a while now, it's a pity that torchvision for M1 is not available in nightlies yet

Motivation, pitch

It should be pretty simple - just add a CI workflow that downloads M1 package (actually even x86_64 one will do, as symbols should be identical) and compiles it by passing "-arch arm64" option, i.e. something along those lines:

% git diff
diff --git a/setup.py b/setup.py
index a62895d76..f211411e4 100644
--- a/setup.py
+++ b/setup.py
@@ -181,7 +181,7 @@ def get_extensions():
 
     define_macros = []
 
-    extra_compile_args = {"cxx": []}
+    extra_compile_args = {"cxx": ["-arch", "arm64"]}
     if (torch.cuda.is_available() and ((CUDA_HOME is not None) or is_rocm_pytorch)) or os.getenv(
         "FORCE_CUDA", "0"
     ) == "1":

Alternatives

Keep building torchvision manually at irregular cadence

Additional context

No response

cc @seemethere

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions