Overview
PyTorch 2.4, released on July 25, 2024, adds official Python 3.12 support and continues improving torch.compile.
Main Features
Python 3.12
PyTorch officially supports Python 3.12, with precompiled wheels available on PyPI for all platforms.
python
import torch
import sys
print(f'Python {sys.version}')
print(f'PyTorch {torch.__version__}')
print(f'CUDA available: {torch.cuda.is_available()}')
# torch.compile works with Python 3.12
@torch.compile
def compute(x):
return torch.nn.functional.gelu(x) * 2
print(compute(torch.randn(4)))
