The installation of PyTorch is pretty straightforward and can be done on all major operating systems. However, if you want to get your hands dirty without actually installing it, Google Colab provides a good starting point.

Colab comes with preinstalled PyTorch and Tensorflow modules and works with both GPU and TPU support.

For installation on your own computer, PyTorch comes with both the CUDA and no CUDA versions, depending upon the hardware available to you.

This will be a single step installation – PyTorch Start Locally.

Prerequisite: Anaconda Distribution (Link to official website) – You need Anaconda installed on your system to follow this tutorial. The download packages are available for all major operating systems and the process of installation is very straight forward.

So before you go ahead with the tutorial, make sure you have an up and running Anaconda distribution set up on your operating system.

Note: In case you don’t want to use Anaconda, you can always use PIP to install PyTorch. Since PIP comes bundled with Python installer, you will already have it in your system.

Install Pytorch on Windows

The PyTorch website provides the following command for the windows system. PyTorch works with Windows 7 or higher and uses Python 3 or higher. Installing it using Anaconda is quite simple and can be done in a few minutes.

PyTorch-Installation-1

PyTorch Installation 1

The next step is to paste the following command in your Anaconda prompt and run it.

The prompt will list out all the dependencies that will be installed along with PyTorch. If you are okay to proceed, type yes in the command line.

PyTorch-Installation-1

PyTorch Installation 2

Anaconda now proceeds with the installation. You can check the installation through the Python interpreter or a Jupyter Notebook later.

PyTorch-Version

PyTorch Version

Now you have successfully installed PyTorch on your Windows system.

Installing PyTorch on Linux

If you open the same installation page from a Linux machine, you will notice that the generated command will be a different one.

PyTorch-Installation-1

PyTorch Linux

The next step is to copy and paste the command into your terminal and run it.

Pytorch Ubuntu Installation

The terminal asks you for permission to install/update packages. You need to press yes as a response.

pytorch-ubuntu-packages

Pytorch Ubuntu Packages

The installation will now continue to install torch and torchvision packages into your environment.

pytorch-ubuntu-progress

Pytorch Ubuntu Progress

Installing PyTorch on Mac OS

We will use PIP to install PyTorch in Mac OS. All we need is to select the appropriate options on the PyTorch home page to get the install command.

PyTorch-Installation-1

Pytorch Quick Start Locally Mac Os

So, we have to run the following command to install PyTorch and torchvision libraries on Mac OS.

Here is the output from the Terminal when the above command is executed.

pip-install-torch-1024x376

Pip Install Torch

The last line of the output clearly states that both torch and torchvision packages are successfully installed.

Let’s launch the Python 3.7 interpreter and print the torch version to confirm the successful installation.

Python Print Torch Version

Conclusion

PyTorch is a very powerful machine learning framework. It’s used a lot in creating deep learning by processing large amounts of data. We will look into more features of PyTorch in the upcoming tutorials.

By admin

Leave a Reply

%d bloggers like this: