Menu
03/15/2025Cooper Reagan
How to check PyTorch version?
Publication Date 03/15/2025
Category: Articles
Reading Time 2 Min

How to check PyTorch version?

To check the version of PyTorch installed in your environment, you can use one of the following methods. Choose the one that suits your setup best.

Method 1: Using Python Script

  1. Open your Python interpreter or create a new Python script.
  2. Run the following commands:
    import torch
    print(torch.__version__)

    This will output the version of PyTorch currently installed.

Method 2: Using Command Line

You can also check the PyTorch version directly from the command line (Command Prompt, Terminal, or Anaconda Prompt):

  1. Open your command line interface.
  2. Type the following command:
    python -c "import torch; print(torch.__version__)"

    This command executes a small Python snippet that imports the PyTorch library and prints its version.

Method 3: Using Jupyter Notebook

If you are using Jupyter Notebook, you can check the PyTorch version in a notebook cell:

import torch
torch.__version__

This will display the version of PyTorch in the output cell.

Method 4: Using Pip

If you installed PyTorch using pip, you can also check the version by running:

pip show torch

This command will display information about the PyTorch package, including its version.

Conclusion

These methods will help you quickly determine the version of PyTorch installed in your environment. Choose the one that best fits your workflow!

Comments

U
Loading...

Related Posts