python-pytorchHow do I install PyTorch using pip?
Installing PyTorch using pip is a simple process. Here are the steps to follow:
-
Make sure your system has pip installed. If it doesn't, you can install it with
python -m pip install --upgrade pip
-
Select the correct command for your system. For Linux, it is
pip3 install torch torchvision
. For Windows, it ispip install torch===1.6.0 torchvision===0.7.0
-
Execute the command.
$ pip3 install torch torchvision
Collecting torch
Downloading https://files.pythonhosted.org/packages/30/57/d5cceb0799c06733eefce80c395459f28970ebb9e896846ce96ab579a3f1/torch-1.6.0-cp36-cp36m-manylinux1_x86_64.whl (748.0MB)
Collecting torchvision
Downloading https://files.pythonhosted.org/packages/9a/0e/6c7d8c37212d4f9d5f6cae4f3b7b8fc5d6b7f2b89b2b3b4b46e5f7d8a8e2/torchvision-0.7.0-cp36-cp36m-manylinux1_x86_64.whl (6.2MB)
Installing collected packages: torch, torchvision
Successfully installed torch-1.6.0 torchvision-0.7.0
- Verify the installation by importing the library in Python.
$ python
>>> import torch
>>> print(torch.__version__)
1.6.0
- You can also check the version of PyTorch installed by running
pip freeze
command.
$ pip freeze
torch==1.6.0
torchvision==0.7.0
That's it. You have successfully installed PyTorch using pip.
Helpful links
More of Python Pytorch
- How can I use Yolov5 with PyTorch?
- How do I install PyTorch on Ubuntu using Python?
- How can I use Python PyTorch with CUDA?
- How can I use Python and PyTorch to create a U-Net architecture?
- How can I install Python PyTorch on Ubuntu using ROCm?
- How can I use Python, PyTorch, and YOLOv5 to build an object detection model?
- How can I use Python and PyTorch to parse XML files?
- What is the most compatible version of Python to use with PyTorch?
- How do I show the version of PyTorch I am using?
- How can I use a Python PyTorch DataLoader to load data?
See more codes...