In this article, we are going to see how you can install PyTorch in the Linux system. We are using Ubuntu 20 LTS you can use any other one. To successfully install PyTorch in your Linux system, follow the below procedure:
First, check if you are using python’s latest version or not.
Because PyGame requires python 3.7 or a higher version, make sure you are using the latest version of python. Type the below command to check the version of python.
python3 --version
Note: If Python is not installed, refer to install python in Linux.
Check if you are using the latest version of pip or not:
The pip is a python package installer, if you want to use any external package in your python file you first install it in your local system using pip. Run the following command to check the version of pip.
pip3 --version
If you are already using the new pip version so follow the below steps if not, so refer to the article on how to install pip in Linux.
Switch to root user and update Linux packages if you are not using the latest pip version:
Open the terminal and make sure you are the root user. Run the following command to switch to root user.
sudo su
Update Linux packages using the below command.
apt update
After this step, you are ready to install PyTorch on your Linux system.
Installing PyTorch
pip3 install torch==1.8.1+cpu torchvision==0.9.1+cpu torchaudio==0.8.1 -f https://download.pytorch.org/whl/torch_stable.html
The above command was used to install PyTorch in the system that didn't have GPU. You just copy the command and paste it into the terminal and run it.

The below command is used to install PyTorch on a system which has GPU. Make sure you have python 3.7 or higher.
pip3 install torch torchvision torchaudio
To make sure PyTorch is installed in your system, just type python3 in your terminal and run it. After that type import torch for use PyTorch library at last type and run print(torch.__version__) it shows which version of PyTorch was installed on your system if PyTorch was installed on your system.

Similar Reads
Install Tensorflow on Linux In this article, we are going to see how to install TensorFlow in Linux. It is a completely open-source library for numerical computation using data flow graphs. System requirement:Python 3.6 to 3.8.Pip 19.0 or higher.Ubuntu 16.04 or higher.Step-wise installation: Step 1: Create a virtual environmen
1 min read
How to Install Pyproj on Linux? Pyproj is an Interface for the cartographic projections and coordinate transformations library (PROJ). In this article, we will look into the process of installing the Pyproj interface on a Linux machine. Pre-requisites: The only thing that you need for installing Numpy on Windows are: PythonPIP or
2 min read
How to Install Python on Linux This guide explains how to install Python on Linux machines. Python has become an essential programming language for developers, data scientists, and system administrators. It's used for various applications, including web development, data science, automation, and machine learning.This comprehensiv
15+ min read
How to Install PyBrain on Linux? PyBrain is an open-source and free-to-use Python-based Machine Learning Library. Its main purpose is to provide machine learning tasks with flexible, easy-to-use, still a very powerful algorithms. It also provides a wide range of predefined environments which is used to test and compare different ty
2 min read
How to Install Pillow on Linux? In this article, we will look into the various methods of installing the PIL package on a Linux machine. Python Imaging Library (expansion of PIL) is the de facto image processing package for Python language. It incorporates lightweight image processing tools that aid in editing, creating, and savin
2 min read
How to Install NLTK on Linux? NLTK is Natural Language Tool Kit. It is used to build python programming. It helps to work with human languages data. It gives a very easy user interface. It supports classification, steaming, tagging, etc. In this article, we will look into the process of installing NLTK on Linux. Installing NLTK
1 min read