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 thesys
module, which provides access to information about the Python interpreter. -
import torch
- This imports thetorch
module, 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 can I use Python, PyTorch, and YOLOv5 to build an object detection model?
- How do I install PyTorch on Ubuntu using Python?
- How can I use Python PyTorch with CUDA?
- How can I use Yolov5 with PyTorch?
- How can I use Python and PyTorch to parse XML files?
- How do I use Pytorch with Python 3.11 on Windows?
- How do I install a Python PyTorch .whl file?
- How do I use PyTorch with Python version 3.11?
- How can I use Python and PyTorch to create an Optical Character Recognition (OCR) system?
- How do I check the version of Python and PyTorch I am using?
See more codes...