python-pytorchHow do I determine the version of Python and PyTorch I'm using?
You can determine the version of Python and PyTorch you are using by running the following code:
import sys
import torch
print('Python version:', sys.version)
print('PyTorch version:', torch.__version__)
Output example
Python version: 3.7.7 (default, Mar 10 2020, 15:43:33)
[Clang 11.0.0 (clang-1100.0.33.17)]
PyTorch version: 1.5.1+cu101
The code is composed of the following parts:
-
import sys- This imports thesysmodule, which provides access to information about the Python interpreter. -
import torch- This imports thetorchmodule, which provides access to PyTorch functions and classes. -
print('Python version:', sys.version)- This prints the version of Python being used. -
print('PyTorch version:', torch.__version__)- This prints the version of PyTorch being used.
Helpful links
More of Python Pytorch
- How do I use PyTorch with Python version 3.11?
- How can I use Python and PyTorch to parse XML files?
- How can I use Python, PyTorch, and YOLOv5 to build an object detection model?
- How can I use Python PyTorch without a GPU?
- What is the most compatible version of Python to use with PyTorch?
- How do I uninstall Python PyTorch?
- How can I compare Python PyTorch and Torch for software development?
- How do I check the version of Python and PyTorch I am using?
- How do I install PyTorch on Ubuntu using Python?
See more codes...