Can’t create arm64 version of mv3_coreml_all.pte model for XCode project

Following instructions from (executorch/examples/demo-apps/apple_ios at main · pytorch/executorch · GitHub)

error on python3 -m examples.apple.coreml.scripts.export --model_name=“mv3"

import executorchcoreml

ImportError: dlopen(/Users/…/executorch/.venv/lib/python3.12/site-packages/executorchcoreml.cpython-312-darwin.so, 0x0002): tried: ‘/Users/…/executorch/.venv/lib/python3.12/site-packages/executorchcoreml.cpython-312-darwin.so’ (mach-o file, but is an incompatible architecture (have ‘x86_64’, need ‘arm64e’ or ‘arm64’)), ‘/System/Volumes/Preboot/Cryptexes/OS/Users/…/executorch/.venv/lib/python3.12/site-packages/executorchcoreml.cpython-312-darwin.so’ (no such file), ‘/Users/…/executorch/.venv/lib/python3.12/site-packages/executorchcoreml.cpython-312-darwin.so’ (mach-o file, but is an incompatible architecture (have ‘x86_64’, need ‘arm64e’ or 'arm64’))

yet the other models built fine: mv3_mps.pte , mv3_xnnpack_fp32.pte, mv3.pte, imagenet_classes

Hi, thanks for your question! I’ll forward this to the iOS expert on my team. Please allow us to have some time looking at it.

Hi @swainwri, please try the following in a new Terminal window:

git clone https://github.com/pytorch/executorch.git --recursive && cd executorch

python3 -m venv .venv && source .venv/bin/activate

pip install --upgrade cmake pip setuptools wheel

./install_requirements.sh

./backends/apple/coreml/scripts/install_requirements.sh

python3 -m examples.apple.coreml.scripts.export --model_name="mv3"

Appreciate your time.

I followed your instructions,

(.venv) t@MacBook-Air executorch % python3 -m examples.apple.coreml.scripts.export --model_name=“mv3”

Torch version 2.5.0.dev20240912 has not been tested with coremltools. You may run into unexpected errors. Torch 2.4.0 is the most recent version that has been tested.

Fail to import BlobReader from libmilstoragepython. No module named ‘coremltools.libmilstoragepython’

Failed to load _MLModelProxy: No module named ‘coremltools.libcoremlpython’

Fail to import BlobWriter from libmilstoragepython. No module named ‘coremltools.libmilstoragepython’

Traceback (most recent call last):

File “”, line 198, in _run_module_as_main

File “”, line 88, in _run_code

File “/Users/stevewainwright/executorch/examples/apple/coreml/scripts/export.py”, line 13, in

import executorch.exir as exir

ModuleNotFoundError: No module named ‘executorch’

here’s the output from all your instructions

(Attachment Executorch.txt.zip is missing)