Concepts / Introduction to PyTorch

Introduction to PyTorch

Many scientific computing libraries do not immediately support the newest version of Python, so the latest release is not always the best choice for PyTorch.

  • Programming

The Newest-Version Instinct

When people set up a new machine for machine learning, a natural instinct is to install the newest version of everything. That instinct is reasonable for many tools, but for Python it can cause trouble once the next step is installing PyTorch. The newest Python release is not automatically the most suitable one for this purpose.

The key idea is that before you install PyTorch, you need to think about which Python version you are installing it into, and why the most recent release may not be the right match. Many scientific computing libraries do not immediately support the newest version of Python, and PyTorch sits in that group of tools.

What do you think happens?

If the latest Python release is 3.13, which version does the guideline suggest for installing PyTorch?

  • 3.13, because it is the latest

  • 3.12 or 3.11

  • 3.9 or older

Reveal answer
Answer:

3.11 or 3.12

The guideline is to use a version one or two releases older than the latest. With 3.13 as the latest, that means 3.12 (one release older) or 3.11 (two releases older).

The One-or-Two-Releases-Back Rule

The guideline for choosing a Python version for PyTorch is to use a version that is one or two releases older than the latest release. The latest release acts as the reference point. You then look at the releases just below it and choose one of those two.

The source gives a concrete case. When the latest release is 3.13, it recommends Python 3.11 or 3.12 for installing PyTorch. Both are older than the newest release, and each sits within the one-or-two-releases-back window.

3.11two releases back3.12one release back3.13latest releasenext releasenext release
With 3.13 as the latest release, the two versions just below it, 3.12 and 3.11, are the recommended choices for installing PyTorch.

The rule is a relative one, so you apply it to whatever the latest release is at the time you install. The fixed numbers in the example are only one application of it. The question to ask is always the same: which release is the latest, and which one or two releases sit just beneath it?

In the real world

Suppose a learner reads this article when the newest release is some version N. Using the rule, the candidates are N minus one and N minus two. The learner does not need to memorize a list of version numbers. They only need to find the latest release and count back one or two.

Why Libraries Lag Behind New Releases

The reason the guideline exists is that many scientific computing libraries do not immediately support the newest version of Python. A brand-new release is available to everyone on the day it ships, but the libraries that depend on Python may take time to catch up. If you install PyTorch into a version that those libraries do not yet fully support, the setup can run into trouble.

The diagram below is a simplified view of that delay. It is not a precise description of how any particular library is built. It only shows the order of events the guideline is responding to: a release appears first, and library support follows afterward.

New Python releasenewest version availableLibraries catch upsupport arrives laterPyTorch installworks smoothly on supportedversionsdelayenables
A new Python release arrives first, and scientific libraries such as PyTorch may not yet support it. Installing PyTorch into that release is where the trouble can start.

Deciding on the Version First

The source's central advice is to think about the Python version before you install PyTorch, rather than defaulting to the newest release. In practice, this means treating the version choice as a deliberate first step in the setup rather than an afterthought.

  1. 1
    Find out which Python release is the latest one available.
  2. 2
    Count back one or two releases from that latest release.
  3. 3
    Choose one of those two older releases as the Python version for your PyTorch installation.
  4. 4
    Install PyTorch into that chosen version rather than into the newest release by default.

Worked Example: Setting Up a New Machine

Worked example

Choosing a Python Version for a New Machine Learning Setup

A learner is setting up a new computer for machine learning and wants to install PyTorch. The latest Python release is 3.13. Which Python version should the learner use for the PyTorch installation, and why not simply install the newest version?

  1. 1
    Recognize the instinct

    The learner's first impulse is to install the newest version of everything, including Python 3.13.

  2. 2
    Recall the reason to pause

    Many scientific computing libraries do not immediately support the newest version of Python, so the newest release is not automatically the right one for PyTorch.

  3. 3
    Apply the guideline

    Count back one or two releases from 3.13. One release back is 3.12, and two releases back is 3.11.

  4. 4
    Select a version

    Either 3.11 or 3.12 is a recommended choice for installing PyTorch, based on the guideline.

  5. 5
    Install into the chosen version

    The learner installs PyTorch into the selected older release instead of the newest one, so the setup matches the versions the guideline points toward.

Result

The learner uses Python 3.12 or 3.11 for the PyTorch installation rather than 3.13, because the newest release may not yet be fully supported by the libraries PyTorch relies on.

Mistakes From Always Installing the Newest Python

  • Common mistake

    Assuming the newest Python release is automatically the most suitable one for PyTorch

    What it looks like

    A learner installs the latest Python release on a new machine and then adds PyTorch to it without checking anything else.

    Why it fails

    Many scientific computing libraries do not immediately support the newest version of Python, so the newest release is not always the best match for PyTorch.

    Do this instead

    Pause before installing and choose a version one or two releases older than the latest.

  • Common mistake

    Treating the Python version as an afterthought

    What it looks like

    A learner installs Python and PyTorch in quick succession without ever deciding which Python version the PyTorch installation should target.

    Why it fails

    The source advises thinking about which Python version you are installing PyTorch into before you install it.

    Do this instead

    Make the version decision first, then install PyTorch into that chosen version.

  • Common mistake

    Applying the guideline to a fixed set of version numbers

    What it looks like

    A learner memorizes that 3.11 and 3.12 are good choices and keeps using them forever, even after the latest release changes.

    Why it fails

    The guideline is relative to the latest release, so the right versions move as new releases appear.

    Do this instead

    Find the current latest release each time, then count back one or two releases from it.

  • Common mistake

    Ignoring the question of library support when a new release arrives

Practice: Applying the Guideline

EASY

Imagine the latest Python release is 3.13. A friend asks you which Python version they should use when installing PyTorch on a new laptop. Explain which versions you would recommend, why you would not recommend 3.13, and what general rule you would give them so they can apply it later when a newer release appears.

Hints
  • Start by identifying the latest release, then count back one or two releases from it.
  • Think about why many scientific computing libraries might not yet support the newest release.
  • Your general rule should refer to the latest release at the time of installation, not to fixed numbers.

Key Takeaways

  • The newest Python release is not always the best choice for installing PyTorch, because many scientific computing libraries do not immediately support it.
  • The guideline is to use a Python version one or two releases older than the latest release; with 3.13 as the latest, the source recommends 3.11 or 3.12.
  • Think about which Python version you are installing PyTorch into before you install it, rather than defaulting to the newest release.
  • Common mistakes include assuming the newest release is automatically suitable, treating the version choice as an afterthought, and memorizing fixed version numbers instead of applying the relative rule.

Related concepts

More concepts starting with I