how to install pytorch using pip code example

Example 1: pytorch install

pip install torch==1.8.1+cu102 torchvision==0.9.1+cu102 torchaudio===0.8.1 -f https://download.pytorch.org/whl/torch_stable.html

Example 2: pip install pytorch windows

conda install pytorch torchvision torchaudio cudatoolkit=10.2 -c pytorch

Example 3: mac install pytorch 3.6

conda install pytorch torchvision -c pytorch

Example 4: torch import

import torch
import torch.nn as nn
import torch.nn.functional as F
from torch.utils.data import DataLoader
from torchvision import datasets, transforms, models
from torchvision.utils import make_grid

import numpy as np
import pandas as pd
from sklearn.metrics import confusion_matrix
import matplotlib.pyplot as plt
%matplotlib inline

transform = transforms.ToTensor()

train_data = datasets.FashionMNIST(root='../Data', train=True, download=True, transform=transform)
test_data = datasets.FashionMNIST(root='../Data', train=False, download=True, transform=transform)

Example 5: install pytorch

NOTE: Python 3.9 users will need to add '-c=conda-forge' for installationconda install pytorch torchvision torchaudio cudatoolkit=10.2 -c pytorch