How To Install PyTorch Using pip: A Step-by-Step Guide

Installing PyTorch with pip

In this guide, you'll learn how to install PyTorch using pip, the popular Python package installer.

Check Python Version

Ensure Python is installed. Type python --version in your terminal. PyTorch requires Python 3.6 or higher.

Install pip

If you don't have pip, install it by typing python -m ensurepip --upgrade or python -m pip install --upgrade pip.

Choose PyTorch Version

Visit the PyTorch website and choose the version suited for your environment, whether it's CPU or GPU.

Install PyTorch

Run the pip command from the PyTorch site. Example: pip install torch torchvision torchaudio.

Verify Installation

Confirm the installation by typing import torch in Python. No errors mean PyTorch is installed successfully.