Skip to content
Related Articles

Related Articles

Improve Article
Save Article
Like Article

Install Pytorch on Linux

  • Last Updated : 06 Oct, 2021

In this article, we are going to how to 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 you are using python’s latest version or not.

Because the PyGame is only supported python 3.7.7 or higher version so make sure you are using the latest version of python. Type the below command to the check the version of the article.

python3 –version

Note: If Python is not installed refer to install python in the Linux system.

Check you are using pip the latest version 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, so the pip tool is used. 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 the Linux system.

pip3 –version

Make 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.

sudo s

Type your password and doing the below process as a root user and update Linux packages using the below command.

apt update

After doing the step you are ready to install PyTorch in your Linux system.

Installing PyTorch

pip3 install torch==1.8.1+cpu torchvision==0.9.1+cpu torchaudio==0.8.1 -f

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 in the system which has GPU. Make sure you have python 3.6 or 3.7 or 3.8.

pip3 install torch torchvision torchaudio

To make sure PyTorch is installed in your system just type python3 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 in your system if PyTorch was installed in your system.

 Attention geek! Strengthen your foundations with the Python Programming Foundation Course and learn the basics.  

To begin with, your interview preparations Enhance your Data Structures concepts with the Python DS Course. And to begin with your Machine Learning Journey, join the Machine Learning - Basic Level Course

My Personal Notes arrow_drop_up
Recommended Articles
Page :

Start Your Coding Journey Now!