Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/pytorch/vision/llms.txt

Use this file to discover all available pages before exploring further.

Installing TorchVision correctly means installing it alongside a compatible version of PyTorch for your operating system, Python version, and hardware (CPU, CUDA, or ROCm). The fastest path for most users is the official PyTorch installer wizard at pytorch.org/get-started/locally, which generates the exact command for your environment. The sections below cover every common scenario in detail.

Quick Install

The recommended way to install TorchVision is to install it together with PyTorch in a single command. Both pip and conda are fully supported.
pip install torch torchvision
Always install torch and torchvision in the same command. Installing them separately can result in version mismatches that cause cryptic import errors or silent numerical bugs.

Version Compatibility

Each TorchVision release is paired with a specific PyTorch release. Use the table below to choose matching versions, or let the official wizard pick for you.
torchtorchvisionPython
2.120.27>=3.10, <=3.14
2.110.26>=3.10, <=3.14
2.100.25>=3.10, <=3.14
2.90.24>=3.10, <=3.14
2.80.23>=3.9, <=3.13
2.70.22>=3.9, <=3.13
2.60.21>=3.9, <=3.12
To pin specific versions with pip:
pip install torch==2.6.0 torchvision==0.21.0 --index-url https://download.pytorch.org/whl/cu126

Verify Your Installation

After installing, run the following to confirm both packages are importable and report the expected versions:
import torch
import torchvision

print(torch.__version__)        # e.g. 2.6.0+cu126
print(torchvision.__version__)  # e.g. 0.21.0+cu126
If either import fails, the most common cause is a version mismatch. Re-install both packages in a single command as shown above.

CUDA Versions

TorchVision ships pre-built wheels for the CUDA versions supported by the corresponding PyTorch release. The index URL you pass to pip selects the CUDA build:
CUDA version--index-url
CPU onlyhttps://download.pytorch.org/whl/cpu
CUDA 12.6https://download.pytorch.org/whl/cu126
CUDA 12.8https://download.pytorch.org/whl/cu128
ROCm 6.2https://download.pytorch.org/whl/rocm6.2
Your CUDA version must match the version of the CUDA toolkit installed on your system. Run nvcc --version or nvidia-smi to check.

Build From Source

Building from source is required when contributing to TorchVision or when you need a build targeting a non-standard CUDA version. Start with the nightly PyTorch build, then clone and install TorchVision in editable mode:
# 1. Install nightly PyTorch (see pytorch.org for the exact command)
pip install --pre torch --index-url https://download.pytorch.org/whl/nightly/cu126

# 2. (Optional) Install native codec libraries for fast image I/O
conda install libpng libjpeg-turbo libwebp -c pytorch

# 3. Clone and build TorchVision
git clone https://github.com/pytorch/vision.git
cd vision
pip install -e . -v --no-build-isolation
On macOS, prefix the pip install with compiler flags:
MACOSX_DEPLOYMENT_TARGET=10.9 CC=clang CXX=clang++ pip install -e . -v --no-build-isolation
GPU support is built automatically when CUDA is detected. To force a CUDA build regardless:
FORCE_CUDA=1 pip install -e . -v --no-build-isolation
Use TORCHVISION_INCLUDE and TORCHVISION_LIBRARY environment variables to point the build system at non-standard locations for libpng, libjpeg-turbo, or libwebp.

Optional Native Dependencies

TorchVision’s torchvision.io module can use native C++ codecs for significantly faster image reading and writing when the following libraries are present at build time:
LibraryPurposeInstall (conda)
libpngNative PNG encode / decodeconda install libpng -c pytorch
libjpeg-turboFast JPEG encode / decode (SIMD)conda install libjpeg-turbo -c pytorch
libwebpWebP encode / decodeconda install libwebp -c pytorch
Without these libraries, torchvision.io falls back to a slower pure-Python path via Pillow.

Configuring Image Backends

TorchVision defaults to PIL (Pillow) for image loading. You can switch to the faster accimage backend (Intel IPP) at runtime:
import torchvision

# Set backend to accimage (must be installed separately: pip install accimage)
torchvision.set_image_backend("accimage")

# Verify
print(torchvision.get_image_backend())  # "accimage"

# Revert to PIL
torchvision.set_image_backend("PIL")
Valid values for set_image_backend are "PIL" and "accimage". Passing any other string raises a ValueError.

Configuring Video Backends

TorchVision uses PyAV (Python FFmpeg bindings) as its video backend. PyAV is installed automatically as a dependency and requires no configuration for typical use:
import torchvision

# Query the active video backend
print(torchvision.get_video_backend())  # "pyav"
PyAV wraps the FFmpeg libraries. For GPU-accelerated video decoding, ensure that your FFmpeg build was compiled with the appropriate hardware acceleration flags.

Build docs developers (and LLMs) love