Skip to main content

Install PyTorch and TorchVision

My suggestion is to install these packages from pre-built Python wheels directly. This saves a lot of time and trouble as long as you have installed the correct NVIDIA driver and CUDA toolkit.

sudo pip3 install torch torchvision --index-url https://download.pytorch.org/whl/cu132 --break-system-packages

Validation

Verify that PyTorch and TorchVision are installed correctly and that the GPU is accessible:

import torch
torch.__version__ # '2.12.0+cu132'
torch.cuda.is_available() # True

import torchvision
torchvision.__version__ # '0.27.0+cu132'

Expected output:

'2.12.0+cu132'
True
'0.27.0+cu132'