Pip install pytorch or conda install pytorch

Test for installation successfully \ \ \ > > > > > > > > >
import torch

## GPU
print(torch.cuda.is_available())
print(torch.backends.cudnn.is_available())
print(torch.cuda_version)
print(torch.backends.cudnn.version())

## CPU
print(torch.__version__)

window conditions: CPU
conda install pytorch torchvision torchaudio cpuonly -c pytorch
pip3 install torch torchvision torchaudio

Windows condition: CUDA11.3
conda install pytorch torchvision torchaudio cudatoolkit=11.3 -c pytorch
pip3 install torch torchvision torchaudio –extra-index-url download.pytorch.org/whl/cu113

Windows condition: CUDA11.6
pip3 install torch torchvision torchaudio –extra-index-url download.pytorch.org/whl/cu116

Linux Condition: CPU
conda install pytorch torchvision torchaudio cpuonly -c pytorch
pip3 install torch torchvision torchaudio –extra-index-url download.pytorch.org/whl/cpu

Linux Condition: CUDA 10.2
conda install pytorch torchvision torchaudio cudatoolkit=10.2 -c pytorch
pip3 install torch torchvision torchaudio

Linux Condition: CUDA11.3
conda install pytorch torchvision torchaudio cudatoolkit=11.3 -c pytorch
pip3 install torch torchvision torchaudio –extra-index-url download.pytorch.org/whl/cu113

Linux Condition: CUDA11.6
pip3 install torch torchvision torchaudio –extra-index-url download.pytorch.org/whl/cu116

Read more here: Source link