Skip to content
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

Add Python 3.11 support #4490

Merged
merged 17 commits into from Nov 16, 2022
Merged

Add Python 3.11 support #4490

merged 17 commits into from Nov 16, 2022

Conversation

jcwchen
Copy link
Member

@jcwchen jcwchen commented Sep 6, 2022

Description

Add Python 3.11 support in the future. For now, verify Python 3.11 support first.

Motivation and Context

Closes #4387.

Signed-off-by: Chun-Wei Chen <jacky82226@gmail.com>
@jcwchen jcwchen requested a review from a team as a code owner September 6, 2022 16:55
@jcwchen jcwchen marked this pull request as draft September 6, 2022 16:55
@jcwchen jcwchen added CI pipelines Issues related to the CI pipeline run release CIs Use this label to trigger release tests in CI labels Sep 6, 2022
@jcwchen jcwchen closed this Sep 6, 2022
@jcwchen jcwchen reopened this Sep 6, 2022
Signed-off-by: Chun-Wei Chen <jacky82226@gmail.com>
Signed-off-by: Chun-Wei Chen <jacky82226@gmail.com>
@yan12125
Copy link

yan12125 commented Oct 8, 2022

Building on 3.11 fails with: (from https://github.com/onnx/onnx/actions/runs/3002313403/jobs/4819386269)

/Users/runner/work/onnx/onnx/third_party/pybind11/include/pybind11/detail/type_caster_base.h:482:26: error: member access into incomplete type 'PyFrameObject' (aka '_frame')
            frame = frame->f_back;
                         ^

Looks like the issue is in third_party/pybind11, and it is fixed with pybind11 2.10.0: pybind/pybind11@42a8e31.

@yan12125
Copy link

yan12125 commented Nov 8, 2022

Thanks for the update! Builds and tests now pass on Mac. The only remaining issue on Mac is missing 3.11 support for onnxruntime (microsoft/onnxruntime#13482)

(From https://github.com/onnx/onnx/actions/runs/3415387401/jobs/5684459897)

Run python -m pip install -q onnxruntime
ERROR: Could not find a version that satisfies the requirement onnxruntime (from versions: none)
ERROR: No matching distribution found for onnxruntime


On the other hand, builds on Linux fails as the pip path is incorrect

(From https://github.com/onnx/onnx/actions/runs/3415387398/jobs/5684459657)

/opt/python//bin/pip install --no-cache-dir -q --upgrade pip
.github/workflows/manylinux/entrypoint.sh: line 26: /opt/python//bin/pip: No such file or directory

The cause seems a mismatch between the Python version (3.11-dev) and the shell variable python_map, which uses 3.11.

Signed-off-by: Chun-Wei Chen <jacky82226@gmail.com>
Signed-off-by: Chun-Wei Chen <jacky82226@gmail.com>
@jcwchen
Copy link
Member Author

jcwchen commented Nov 8, 2022

Hi @yan12125, thank you for the pointers! I think now all Python 3.11 related CIs have passed. That is to say, at least now the latest main branch of ONNX should work with Python 3.11.

@cjvolzka
Copy link
Contributor

cjvolzka commented Nov 8, 2022

Two questions:

  1. I see Python 3.7 references removed in the PR. Is support for it being dropped?
  2. What onnx is this targeted for? I'm guessing it's too late for 1.13 (let me know if I'm wrong) so is this targeting 1.14?

@jcwchen
Copy link
Member Author

jcwchen commented Nov 8, 2022

I see Python 3.7 references removed in the PR. Is support for it being dropped?

Python 3.7's EOL is (27 Jun 2023) so ONNX won't deprecate 3.7 in the near future (at least upcoming 1.13 release will still support it).

What onnx is this targeted for? I'm guessing it's too late for 1.13 (let me know if I'm wrong) so is this targeting 1.14?

This PR is only for testing Python 3.11 with the latest main branch and I am not planning to merge it soon (so it's a draft). The bottleneck here is the current used NumPy version 1.21.5 in ONNX does not work well with Python 3.11.... A newer NumPy version 1.23.2 works well with Python 3.11, but it does not work well with Python 3.7. Definitely this PR won't be included in the upcoming 1.13 release, but we will need to make the decision that whether upgrading NumPy version to support Python 3.11 wheel in the next 1.14 release.

@yan12125
Copy link

yan12125 commented Nov 9, 2022

Glad to help, and it's great to see ONNX works on 3.11! Will the pybind11 update (#4635) be part of 1.13? We build python-onnx from sources, and it will be great if the new version can be built on Python 3.11 out of box.

@jcwchen
Copy link
Member Author

jcwchen commented Nov 9, 2022

Will the pybind11 update (#4635) be part of 1.13? We build python-onnx from sources, and it will be great if the new version can be built on Python 3.11 out of box.

Yes it will!

@daquexian
Copy link
Member

The bottleneck here is the current used NumPy version 1.21.5 in ONNX does not work well with Python 3.11.... A newer NumPy version 1.23.2 works well with Python 3.11, but it does not work well with Python 3.7.

FYI, it is possible to depend on different NumPy version on Python3.7 and 3.11: In requirements.txt, we can write

numpy==1.23.2; python_version >= "3.11"
numpy==1.21.5; python_version < "3.11"

which is called "requirement specifiers"
https://pip.pypa.io/en/stable/reference/requirements-file-format/
https://pip.pypa.io/en/stable/reference/requirement-specifiers/#requirement-specifiers

@gramalingam gramalingam added this to the 1.13 milestone Nov 10, 2022
Signed-off-by: Chun-Wei Chen <jacky82226@gmail.com>
@jcwchen jcwchen marked this pull request as ready for review November 10, 2022 18:15
Signed-off-by: Chun-Wei Chen <jacky82226@gmail.com>
Signed-off-by: Chun-Wei Chen <jacky82226@gmail.com>
@jcwchen
Copy link
Member Author

jcwchen commented Nov 10, 2022

Thank you @daquexian for letting me know. Previously I was worried that using inconsistent dependency might be a potential issue, but in fact ONNX itself does not have strong NumPy version requirement. In addition, we do see there are quite a few issues related to Python 3.11 support. Adding Python 3.11 support early can prevent a lot of similar issues coming up in the future.

After discussion with the ONNX infra team, we think we can add Python 3.11 support in the upcoming ONNX 1.13 release.

cc @cjvolzka @yan12125 for awareness.

@jcwchen jcwchen changed the title [WIP] Add Python 3.11 support Add Python 3.11 support Nov 10, 2022
Signed-off-by: jcwchen <jacky82226@gmail.com>
Signed-off-by: Chun-Wei Chen <jacky82226@gmail.com>
… jcw/add-py3.11

Signed-off-by: Chun-Wei Chen <jacky82226@gmail.com>

# Conflicts:
#	.github/workflows/manylinux/entrypoint.sh
Signed-off-by: Chun-Wei Chen <jacky82226@gmail.com>
@jcwchen jcwchen enabled auto-merge (squash) November 16, 2022 21:41
@jcwchen jcwchen merged commit 466edb7 into onnx:main Nov 16, 2022
@jcwchen jcwchen deleted the jcw/add-py3.11 branch January 10, 2023 23:30
justinchuby pushed a commit to justinchuby/onnx that referenced this pull request Jan 27, 2023
* add Python 3.11 support

Signed-off-by: Chun-Wei Chen <jacky82226@gmail.com>

* install higher version of numpy for 3.11

Signed-off-by: Chun-Wei Chen <jacky82226@gmail.com>

* typo

Signed-off-by: Chun-Wei Chen <jacky82226@gmail.com>

* use 3.11 instead of 3.11-dev

Signed-off-by: Chun-Wei Chen <jacky82226@gmail.com>

* cp311-cp311

Signed-off-by: Chun-Wei Chen <jacky82226@gmail.com>

* specify requirement for 3.11

Signed-off-by: Chun-Wei Chen <jacky82226@gmail.com>

* different mini numpy requirement

Signed-off-by: Chun-Wei Chen <jacky82226@gmail.com>

* only keep Windows

Signed-off-by: Chun-Wei Chen <jacky82226@gmail.com>

* typo

Signed-off-by: jcwchen <jacky82226@gmail.com>

* add 3.7m back

Signed-off-by: Chun-Wei Chen <jacky82226@gmail.com>

* remove comma

Signed-off-by: Chun-Wei Chen <jacky82226@gmail.com>

Signed-off-by: Chun-Wei Chen <jacky82226@gmail.com>
Signed-off-by: jcwchen <jacky82226@gmail.com>
broune pushed a commit to broune/onnx that referenced this pull request May 6, 2023
* add Python 3.11 support

Signed-off-by: Chun-Wei Chen <jacky82226@gmail.com>

* install higher version of numpy for 3.11

Signed-off-by: Chun-Wei Chen <jacky82226@gmail.com>

* typo

Signed-off-by: Chun-Wei Chen <jacky82226@gmail.com>

* use 3.11 instead of 3.11-dev

Signed-off-by: Chun-Wei Chen <jacky82226@gmail.com>

* cp311-cp311

Signed-off-by: Chun-Wei Chen <jacky82226@gmail.com>

* specify requirement for 3.11

Signed-off-by: Chun-Wei Chen <jacky82226@gmail.com>

* different mini numpy requirement

Signed-off-by: Chun-Wei Chen <jacky82226@gmail.com>

* only keep Windows

Signed-off-by: Chun-Wei Chen <jacky82226@gmail.com>

* typo

Signed-off-by: jcwchen <jacky82226@gmail.com>

* add 3.7m back

Signed-off-by: Chun-Wei Chen <jacky82226@gmail.com>

* remove comma

Signed-off-by: Chun-Wei Chen <jacky82226@gmail.com>

Signed-off-by: Chun-Wei Chen <jacky82226@gmail.com>
Signed-off-by: jcwchen <jacky82226@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CI pipelines Issues related to the CI pipeline run release CIs Use this label to trigger release tests in CI
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

[Tracking] Verify Python 3.11 support
6 participants