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

Support Python 3.11 #86566

Closed
8 tasks done
Tracked by #821 ...
EwoutH opened this issue Oct 10, 2022 · 98 comments
Closed
8 tasks done
Tracked by #821 ...

Support Python 3.11 #86566

EwoutH opened this issue Oct 10, 2022 · 98 comments
Labels
enhancement Not as big of a feature, but technically not a bug. Should be easy to fix module: ci Related to continuous integration module: python frontend For issues relating to PyTorch's Python frontend triaged This issue has been looked at a team member, and triaged and prioritized into an appropriate module
Milestone

Comments

@EwoutH
Copy link

EwoutH commented Oct 10, 2022

Currently Python 3.11 isn't fully supported in Pytorch yet, including testing in CI and publishing wheels to PyPI.

Python 3.11 is currently in Release Candidate state and will be released in about two weeks. Major packages like NumPy, Pandas, SciPy and Matplotlib have already uploaded their Python 3.11 wheels to PyPI.

Python 3.11 new features include:

  • PEP 657 -- Include Fine-Grained Error Locations in Tracebacks
  • PEP 654 -- Exception Groups and except*
  • PEP 673 -- Self Type
  • PEP 646-- Variadic Generics
  • PEP 680-- tomllib: Support for Parsing TOML in the Standard Library
  • PEP 675-- Arbitrary Literal String Type
  • PEP 655-- Marking individual TypedDict items as required or potentially-missing
  • bpo-46752-- Introduce task groups to asyncio
  • The Faster Cpython Project is already yielding some exciting results: this version of CPython 3.11 is ~ 19% faster on the geometric mean of the PyPerformance benchmarks, compared to 3.10.0.

Pytorch is an import package in the deep learning stack, so support at release will help speed up Python 3.11 adoption.

It would be great to have full Python 3.11 support in Pytorch by the time Python 3.11.0 gets released, (expected Monday October 6th, 2022). This includes testing in CI and publishing wheels to PyPI.

This issue can be used as a tracking issue. This includes:

  • Pytorch builds fully on Python 3.11
  • All Pytorch tests pass on Python 3.11
  • All CI is run and green on Python 3.11
  • Wheels are uploaded to PyPI for at least one Pytorch release
    • Manylinux (x86_64)
    • Manylinux (aarch64)
    • Windows
    • macOS

cc @seemethere @malfet @pytorch/pytorch-dev-infra @albanD

@malfet malfet added module: ci Related to continuous integration enhancement Not as big of a feature, but technically not a bug. Should be easy to fix module: python frontend For issues relating to PyTorch's Python frontend labels Oct 10, 2022
@malfet
Copy link
Contributor

malfet commented Oct 10, 2022

Nightly builds of python-3.11 wheels is already published to https://download.pytorch.org/whl/nightly but CI can be tricky, in particular around JIT support (which probably needs a separate task)

@albanD
Copy link
Collaborator

albanD commented Oct 10, 2022

I feel like the main blocker for enabling more support is that (at the time where this was added at least) conda didn't had 3.11 support.
This meant that all our usual test environment couldn't be upgraded easily.

@malfet
Copy link
Contributor

malfet commented Oct 10, 2022

@dagitses suggests that it's probably OK to disable JIT tests and have a followup issue for supporting JIT in 3.11.
Also please note that 3.11 is yet not available on Anaconda: https://anaconda.org/anaconda/python

@albanD
Copy link
Collaborator

albanD commented Oct 10, 2022

cc @davidberard98 there will most likely be some non-trivial work needed for JIT to support this that should be planned for ahead of time.

@EwoutH
Copy link
Author

EwoutH commented Oct 11, 2022

Nightly builds of python-3.11 wheels is already published to https://download.pytorch.org/whl/nightly but CI can be tricky, in particular around JIT support (which probably needs a separate task)

Awesome! Do you know if the Python 3.11 wheels will be deployed with the v1.13 release?

@mikaylagawarecki mikaylagawarecki added triaged This issue has been looked at a team member, and triaged and prioritized into an appropriate module and removed triage review labels Oct 17, 2022
@rijobro
Copy link

rijobro commented Oct 25, 2022

conda now has 3.11 support if that is still a blocker! conda install -c conda-forge python

@johnnynunez
Copy link

Yeah! Python 3.11 support please. It should be the default.
Python 3.11 is between 10-60% faster than Python 3.10. On average, we measured a 1.25x speedup on the standard benchmark suite. See Faster CPython for details.
https://docs.python.org/3.11/whatsnew/3.11.html
https://www.phoronix.com/news/Python-3.11-Released

@weiwangmeta
Copy link
Contributor

Yeah! Python 3.11 support please. It should be the default.

cc @malfet @atalman

@seemethere
Copy link
Member

conda now has 3.11 support if that is still a blocker! conda install -c conda-forge python

conda-forge introduces a lot of instability to our CI pipelines so adding conda support should be gated on the default channels having python 3.11 support not conda-forge

@johnnynunez
Copy link

Benchmark https://www.phoronix.com/review/python-311-performance

@MilesCranmer
Copy link
Contributor

MilesCranmer commented Nov 4, 2022

What is the status of this? Python 3.11 was released ~two weeks ago now so it would be great to have torch wheels available relatively soon for downstream projects to work with.

I would be happy with nightly versions too if a stable release will take some more time, although the current binaries are exclusively linux x86: https://download.pytorch.org/whl/nightly/torch/.

@Birch-san
Copy link

Birch-san commented Nov 5, 2022

Nightly builds of python-3.11 wheels is already published to https://download.pytorch.org/whl/nightly

how do I install these?

https://conda.anaconda.org/pytorch-nightly/osx-arm64
image

I only see python 3.10 builds there.

conda couldn't find any 3.11-compatible pytorch build in the pytorch-nightly channel:

conda create -n 11diffnightly -c pytorch-nightly -c defaults -c conda-forge python==3.11.0 pytorch
Collecting package metadata (current_repodata.json): done
Solving environment: failed with repodata from current_repodata.json, will retry with next repodata source.
Collecting package metadata (repodata.json): done
Solving environment: | 
Found conflicts! Looking for incompatible packages.
This can take several minutes.  Press CTRL-C to abort.
Examining pytorch:
^failed

UnsatisfiableError: The following specifications were found to be incompatible with each other:

Output in format: Requested package -> Available versions

Package python conflicts for:
python==3.11.0
pytorch -> python[version='>=3.10,<3.11.0a0|>=3.10,<3.11.0a0|>=3.8,<3.9.0a0|>=3.9,<3.10.0a0|>=3.8,<3.9.0a0|>=3.9,<3.10.0a0',build=*_cpython]
pytorch -> typing_extensions -> python[version='3.10.*|3.6.12|3.6.12|3.7.10|3.7.10|3.7.12|3.8.12|3.9.10|>=3.11,<3.12.0a0|>=3.11,<3.12.0a0|>=3.5|>=3.6|>=3.7|3.7.9|3.6.9|3.6.9|3.6.9|3.6.9|>=3.8|3.8.*|3.9.*',build='2_73_pypy|4_73_pypy|5_73_pypy|5_73_pypy|0_73_pypy|1_73_pypy|*_cpython|0_73_pypy|0_73_pypy|0_73_pypy|3_73_pypy|1_73_pypy|0_73_pypy']The following specifications were found to be incompatible with your system:

  - feature:/osx-arm64::__osx==12.5=0
  - feature:|@/osx-arm64::__osx==12.5=0
  - pytorch -> __osx[version='>=11.0']

Your installed version is: 12.5

@johnnynunez
Copy link

Nightly builds of python-3.11 wheels is already published to https://download.pytorch.org/whl/nightly

how do I install these?

https://conda.anaconda.org/pytorch-nightly/osx-arm64 image

I only see python 3.10 builds there.

conda couldn't find any 3.11-compatible pytorch build in the pytorch-nightly channel:

conda create -n 11diffnightly -c pytorch-nightly -c defaults -c conda-forge python==3.11.0 pytorch
Collecting package metadata (current_repodata.json): done
Solving environment: failed with repodata from current_repodata.json, will retry with next repodata source.
Collecting package metadata (repodata.json): done
Solving environment: | 
Found conflicts! Looking for incompatible packages.
This can take several minutes.  Press CTRL-C to abort.
Examining pytorch:
^failed

UnsatisfiableError: The following specifications were found to be incompatible with each other:

Output in format: Requested package -> Available versions

Package python conflicts for:
python==3.11.0
pytorch -> python[version='>=3.10,<3.11.0a0|>=3.10,<3.11.0a0|>=3.8,<3.9.0a0|>=3.9,<3.10.0a0|>=3.8,<3.9.0a0|>=3.9,<3.10.0a0',build=*_cpython]
pytorch -> typing_extensions -> python[version='3.10.*|3.6.12|3.6.12|3.7.10|3.7.10|3.7.12|3.8.12|3.9.10|>=3.11,<3.12.0a0|>=3.11,<3.12.0a0|>=3.5|>=3.6|>=3.7|3.7.9|3.6.9|3.6.9|3.6.9|3.6.9|>=3.8|3.8.*|3.9.*',build='2_73_pypy|4_73_pypy|5_73_pypy|5_73_pypy|0_73_pypy|1_73_pypy|*_cpython|0_73_pypy|0_73_pypy|0_73_pypy|3_73_pypy|1_73_pypy|0_73_pypy']The following specifications were found to be incompatible with your system:

  - feature:/osx-arm64::__osx==12.5=0
  - feature:|@/osx-arm64::__osx==12.5=0
  - pytorch -> __osx[version='>=11.0']

Your installed version is: 12.5

Screenshot 2022-11-05 at 14 50 17

https://pytorch.org/blog/PyTorch-1.13-release/

@Birch-san
Copy link

okay, so Linux x86 only? thanks for the link.
if an osx-arm64 build were made available: I'd happily try it out.

@ancestor-mithril
Copy link
Contributor

torch.compile, I guess. I came here because I received

Pytorch 2.0.1 should support both Python 3.11 and torch.compile.

@garfieldnate
Copy link

@ancestor-mithril Interesting, maybe the release got messed up or something? I'm using torch 2.0.1, python 3.11.2 on an M1 Mac. torch.version.__version__ gives 2.0.1 and torch.version.git_version gives e9ebda29d87ce0916ab08c06ab26fd3766a870e5. You can see here that the old version check is still there in this commit.

If you download the wheel from PyPi (I'm using OSX- arm64) and inspect the source there directly, you'll see the old check in place there, too.

Should I open a new ticket for this? There may be other things missing from the release, as well.


Here's my env info:

PyTorch version: 2.0.1
Is debug build: False
CUDA used to build PyTorch: None
ROCM used to build PyTorch: N/A

OS: macOS 13.1 (arm64)
GCC version: Could not collect
Clang version: 14.0.3 (clang-1403.0.22.14.1)
CMake version: version 3.25.1
Libc version: N/A

Python version: 3.11.2 (main, Feb 16 2023, 02:55:59) [Clang 14.0.0 (clang-1400.0.29.202)] (64-bit runtime)
Python platform: macOS-13.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 M1 Max

Versions of relevant libraries:
[pip3] numpy==1.25.0
[pip3] torch==2.0.1
[pip3] torchviz==0.0.2
[conda] Could not collect

Trying to use torch.compile leads to this error:

    model = torch.compile(model)
            ^^^^^^^^^^^^^^^^^^^^
  File ".../venv/lib/python3.11/site-packages/torch/__init__.py", line 1441, in compile
    return torch._dynamo.optimize(backend=backend, nopython=fullgraph, dynamic=dynamic, disable=disable)(model)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File ".../venv/lib/python3.11/site-packages/torch/_dynamo/eval_frame.py", line 413, in optimize
    check_if_dynamo_supported()
  File "...venv/lib/python3.11/site-packages/torch/_dynamo/eval_frame.py", line 377, in check_if_dynamo_supported
    raise RuntimeError("Python 3.11+ not yet supported for torch.compile")
RuntimeError: Python 3.11+ not yet supported for torch.compile

@mlazos
Copy link
Contributor

mlazos commented Jun 30, 2023

cc @williamwen42

@malfet
Copy link
Contributor

malfet commented Jun 30, 2023

Pytorch-2.0.1 does not support torch.compile yet, but it should be available in the nightly builds.

@d-kleine
Copy link
Contributor

d-kleine commented Jul 4, 2023

@malfet Just tested the most recent nightly build (2.1.0.dev20230703), both for cuda 11.8 and 12.1: torch.compile() still does not work (yet)

RuntimeError: Windows not yet supported for torch.compile

@brianmatzelle
Copy link

Bypass this on Windows by adding --compile=False to the end of your run statement. Ex:

python train.py config/finetune_conversation.py --compile=False works, whereas
python train.py config/finetune_conversation.py will raise the error

@malfet
Copy link
Contributor

malfet commented Jul 5, 2023

@d-kleine yes, neither cpp compile backend nor triton currently work on Windows, though this is not specific to 3.11, so feel free to open a separate issue (unless one already exits, if that's the case, please ping me on it)
cc: @vladimir-aubrecht

@d-kleine
Copy link
Contributor

d-kleine commented Jul 5, 2023

@malfet Should be covered by #90768, what do you think?

@malfet
Copy link
Contributor

malfet commented Jul 5, 2023

@d-kleine yes it will, thank you

@georgeseifada
Copy link

Will python 3.11 be supported for torch 1.13.1? I get an error from poetry when trying to install it:

RuntimeError

  Unable to find installation candidates for torch (1.13.1)

  at ~/.virtualenvs/sentence-embedding/lib/python3.11/site-packages/poetry/installation/chooser.py:76 in choose_for
       72│ 
       73│             links.append(link)
       74│ 
       75│         if not links:
    →  76│             raise RuntimeError(f"Unable to find installation candidates for {package}")
       77│ 
       78│         # Get the best link
       79│         chosen = max(links, key=lambda link: self._sort_key(package, link))
       80│ 

nim65s added a commit to agimus-project/happypose that referenced this issue Jul 20, 2023
@DarkAlchy
Copy link

Will python 3.11 be supported for torch 1.13.1? I get an error from poetry when trying to install it:

RuntimeError

  Unable to find installation candidates for torch (1.13.1)

  at ~/.virtualenvs/sentence-embedding/lib/python3.11/site-packages/poetry/installation/chooser.py:76 in choose_for
       72│ 
       73│             links.append(link)
       74│ 
       75│         if not links:
    →  76│             raise RuntimeError(f"Unable to find installation candidates for {package}")
       77│ 
       78│         # Get the best link
       79│         chosen = max(links, key=lambda link: self._sort_key(package, link))
       80│ 

Probably about the time 3.12 comes out. /shrug.

@sytelus
Copy link

sytelus commented Sep 2, 2023

It's been almost a year Python 3.11 was released and PyTorch still doesn't support it in stable release :(. Any idea, when the next stable release with Python 3.11 support will be available?

@AntreasAntoniou
Copy link

I am wondering that too, since I consider Pytorch's stable releases to be a heuristic for which python version I should be using. :D

But other than that, for all the sweet and promised gains.

@johnnynunez
Copy link

johnnynunez commented Sep 5, 2023

It's been almost a year Python 3.11 was released and PyTorch still doesn't support it in stable release :(. Any idea, when the next stable release with Python 3.11 support will be available?

pytorch 2.1.0 rc1 is coming. See tracker in issues. Release on october- end of the year

@huydhn
Copy link
Contributor

huydhn commented Sep 5, 2023

3.11 support will be part of 2.1.0 stable release. Here are some future key dates FYI:

  • M4: Release Branch Finalized & Announce Final launch date (week of 09/11/23)
  • M5: External-Facing Content Finalized (09/25/23)
  • M6: Release Day (10/04/23)

So it's Oct 4th.

@crypdick
Copy link

Just in time for things to break with the new Python 3.12 release ;) #114893

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Not as big of a feature, but technically not a bug. Should be easy to fix module: ci Related to continuous integration module: python frontend For issues relating to PyTorch's Python frontend triaged This issue has been looked at a team member, and triaged and prioritized into an appropriate module
Projects
None yet
Development

No branches or pull requests