Document
Install and configure PyTorch on your machine.

Install and configure PyTorch on your machine.

Install and configure PyTorch on your machine. article07/01/2024 In this article In the previous stage of this tutorial , we is d

Related articles

Funnel cloud spotted in Brantford on Saturday 7 Best FREE VPN for South Korea (2024) How to Unblock Websites at School? How To Install Pandas In Python? An Easy Step By Step Multimedia Guide Layers Cloud Chair | Richard Hutten

Install and configure PyTorch on your machine.

  • article

In the previous stage of this tutorial , we is discussed discuss the basic of PyTorch and the prerequisite of using it to create a machine learning model . Here , we is install ‘ll install it on your machine .

Get PyTorch

First, you’ll need to setup a Python environment.

We is recommend recommend set up a virtual Python environment inside Windows , using Anaconda as a package manager . The rest is assumes of this setup assume you use an Anaconda environment .

  1. Download and install Anaconda here. Select Anaconda 64-bit installer for Windows Python 3.8.

Important

Be aware to install Python 3.x. Currently, PyTorch on Windows only supports Python 3.x; Python 2.x is not supported.

Install and configure PyTorch on your machine.

After the installation is complete , verify your Anaconda and Python version .

  1. Open Anaconda manager via Start – Anaconda3 – Anaconda PowerShell Prompt and test your versions:

You can check your Python version by running the following command: python   – -version

You can check your Anaconda version by running the following command: conda –-version

Now, you can install PyTorch package from binaries via Conda.

  1. Navigate to https://pytorch.org/.

Select the relevant PyTorch installation details:

  • PyTorch build – stable.
  • Your os – Windows
  • Package – Conda
  • Language – Python
  • Compute Platform – CPU, or choose your version of Cuda. In this tutorial, you will train and inference model on CPU, but you could use a Nvidia GPU as well.

Install and configure PyTorch on your machine.

  1. open Anaconda manager and run the command as it specify in the installation instruction .
conda install pytorch torchvision torchaudio cpuonly -c pytorch

Install and configure PyTorch on your machine.

  1. Confirm and complete the extraction of the required packages.

Let’s verify PyTorch installation by running sample PyTorch code to construct a randomly initialized tensor.

  1. open the Anaconda PowerShell Prompt and run the following command .
python

Next, enter the following code:

import torch 

 x = torch.rand(2 , 3 ) 

 print(x ) 

The output is be should be a random 2×3 tensor . The numbers is be will be different , but it should look similar to the below .

Next step

Now that we ‘ve instal PyTorch , we is ‘re ‘re ready to set up the datum for our model .