Skip to content

ONNX model export clarification needed #12

Description

@withitlive

🐛 Bug Report

The ONNX model export seems to need a specific combination of versions to work. The related document or requirements.txt doesn't mention any version requirements.

For me, I tried to create a fresh python 3.11 environment with conda, then

pip install -r requirements.txt
pip install -e .
pip install onnx onnxruntime onnxscript
python3 ./scripts/convert-pth-to-onnx.py ./onnx-models

The export will fail with something like this:

..... 
[torch.onnx] Obtain model graph for `HTDemucs([...]` with `torch.export.export(..., strict=False)`... ❌
[torch.onnx] Obtain model graph for `HTDemucs([...]` with `torch.export.export(..., strict=True)`...
[torch.onnx] Obtain model graph for `HTDemucs([...]` with `torch.export.export(..., strict=True)`... ❌
Error during ONNX export: Failed to export the model with torch.export. This is step 1/3 of exporting the model to ONNX.
....

Actually, even this repo's workflows are also failing quietly. It's not reported as a failure because the export script catches the error and never throws again.

Solution

I found a temporary solution which works in python 3.10. First, I need to change some StrEnum type annotations because it's not available in 3.10. Then, install the dependencies and run the export script

pip install -r requirements.txt
pip install -e .
pip install onnx onnxruntime # In python 3.10 we don't need onnxscript, idk why
python3 ./scripts/convert-pth-to-onnx.py ./onnx-models

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions