Skip to content

Unable to run example script to generate Coreml Models #10797

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
771991673 opened this issue May 9, 2025 · 2 comments
Open

Unable to run example script to generate Coreml Models #10797

771991673 opened this issue May 9, 2025 · 2 comments
Labels
module: coreml Issues related to Apple's Core ML delegation and code under backends/apple/coreml/ module: examples Issues related to demos under examples/ triaged This issue has been looked at a team member, and triaged and prioritized into an appropriate module

Comments

@771991673
Copy link

771991673 commented May 9, 2025

🐛 Describe the bug

Hi guys, I just trying to follow the tutorial of converting coreml model in https://github.com/pytorch/executorch/tree/main/examples/apple/coreml

When I run:

python3 -m examples.apple.coreml.scripts.export --model_name add

I got

Intel GPU Support. (Triggered internally at /Users/runner/work/pytorch/pytorch/pytorch/aten/src/ATen/Context.cpp:148.)
  torch._C._set_onednn_allow_tf32(_allow_tf32)
Traceback (most recent call last):
  File "/Users/james/.pyenv/versions/3.10.10/lib/python3.10/runpy.py", line 196, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "/Users/james/.pyenv/versions/3.10.10/lib/python3.10/runpy.py", line 86, in _run_code
    exec(code, run_globals)
  File "/Users/james/PycharmProjects/optimum-executorch-playground/executorch/examples/apple/coreml/scripts/export.py", line 219, in <module>
    main()
  File "/Users/james/PycharmProjects/optimum-executorch-playground/executorch/examples/apple/coreml/scripts/export.py", line 203, in main
    exec_program = export_lowered_module_to_executorch_program(
  File "/Users/james/PycharmProjects/optimum-executorch-playground/executorch/examples/apple/coreml/scripts/export.py", line 117, in export_lowered_module_to_executorch_program
    exec_prog = to_edge(
  File "/Users/james/PycharmProjects/optimum-executorch-playground/executorch/exir/program/_program.py", line 110, in wrapper
    return func(self, *args, **kwargs)
  File "/Users/james/PycharmProjects/optimum-executorch-playground/executorch/exir/program/_program.py", line 1599, in to_executorch
    return ExecutorchProgramManager(
  File "/Users/james/PycharmProjects/optimum-executorch-playground/executorch/exir/program/_program.py", line 1662, in __init__
    self._pte_data, self._tensor_data = serialize_for_executorch(
  File "/Users/james/PycharmProjects/optimum-executorch-playground/executorch/exir/_serialize/_serialize.py", line 50, in serialize_for_executorch
    pte: Cord = _serialize_pte_binary(
  File "/Users/james/PycharmProjects/optimum-executorch-playground/executorch/exir/_serialize/_program.py", line 488, in serialize_pte_binary
    result: _FlatbufferResult = _program_json_to_flatbuffer(
  File "/Users/james/PycharmProjects/optimum-executorch-playground/executorch/exir/_serialize/_flatbuffer.py", line 277, in _program_json_to_flatbuffer
    schema_info = _prepare_schema(
  File "/Users/james/PycharmProjects/optimum-executorch-playground/executorch/exir/_serialize/_flatbuffer.py", line 148, in _prepare_schema
    schemas = _ResourceFiles([program_schema] + deps)
  File "/Users/james/PycharmProjects/optimum-executorch-playground/executorch/exir/_serialize/_flatbuffer.py", line 105, in __init__
    self._files[name] = importlib.resources.read_binary(__package__, name)
  File "/Users/james/.pyenv/versions/3.10.10/lib/python3.10/importlib/resources.py", line 88, in read_binary
    with open_binary(package, resource) as fp:
  File "/Users/james/.pyenv/versions/3.10.10/lib/python3.10/importlib/resources.py", line 46, in open_binary
    return reader.open_resource(resource)
  File "/Users/james/.pyenv/versions/3.10.10/lib/python3.10/importlib/abc.py", line 433, in open_resource
    return self.files().joinpath(resource).open('rb')
  File "/Users/james/.pyenv/versions/3.10.10/lib/python3.10/pathlib.py", line 1119, in open
    return self._accessor.open(self, mode, buffering, encoding, errors,
FileNotFoundError: [Errno 2] No such file or directory: '/Users/james/PycharmProjects/optimum-executorch-playground/executorch/exir/_serialize/program.fbs'

Versions

PyTorch version: 2.8.0.dev20250325
Is debug build: False
CUDA used to build PyTorch: None
ROCM used to build PyTorch: N/A

OS: macOS 15.4.1 (arm64)
GCC version: Could not collect
Clang version: 16.0.0 (clang-1600.0.26.6)
CMake version: version 3.31.6
Libc version: N/A

Python version: 3.10.10 (main, May 6 2025, 11:14:40) [Clang 16.0.0 (clang-1600.0.26.6)] (64-bit runtime)
Python platform: macOS-15.4.1-arm64-arm-64bit
Is CUDA available: False
CUDA runtime version: No CUDA
CUDA_MODULE_LOADING set to: N/A
GPU models and configuration: No CUDA
Nvidia driver version: No CUDA
cuDNN version: No CUDA
HIP runtime version: N/A
MIOpen runtime version: N/A
Is XNNPACK available: True

CPU:
Apple M4

Versions of relevant libraries:
[pip3] executorch==0.7.0a0+1c2b7ba
[pip3] numpy==2.0.0
[pip3] optimum-executorch==0.0.0.dev0
[pip3] pytorch-tokenizers==0.1.0
[pip3] torch==2.8.0.dev20250325
[pip3] torchao==0.12.0+gitc9b9adc7
[pip3] torchaudio==2.6.0.dev20250325
[pip3] torchdata==0.11.0
[pip3] torchsr==1.0.4
[pip3] torchtune==0.6.1
[pip3] torchvision==0.22.0.dev20250325
[conda] No relevant packages

cc @mergennachin @iseeyuan @lucylq @helunwencser @tarun292 @kimishpatel @jackzhxng @YifanShenSZ @cymbalrush @metascroy

@Jack-Khuu Jack-Khuu added triaged This issue has been looked at a team member, and triaged and prioritized into an appropriate module module: coreml Issues related to Apple's Core ML delegation and code under backends/apple/coreml/ module: examples Issues related to demos under examples/ labels May 12, 2025
@github-project-automation github-project-automation bot moved this to To triage in ExecuTorch Core May 12, 2025
@Jack-Khuu
Copy link
Contributor

cc: @cccclai Who is the current owner for backend examples?

@metascroy
Copy link
Contributor

metascroy commented May 12, 2025

@771991673 Usually, FileNotFoundError: [Errno 2] No such file or directory: '/Users/james/PycharmProjects/optimum-executorch-playground/executorch/exir/_serialize/program.fbs'

occurs because you running the script from your local copy of the executorch repo. In this case, python will use the local path instead of the installed path.

Can you try running it from another directory?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
module: coreml Issues related to Apple's Core ML delegation and code under backends/apple/coreml/ module: examples Issues related to demos under examples/ triaged This issue has been looked at a team member, and triaged and prioritized into an appropriate module
Projects
Status: To triage
Development

No branches or pull requests

3 participants