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.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.
Quick Install
The recommended way to install TorchVision is to install it together with PyTorch in a single command. Bothpip and conda are fully supported.
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.torch | torchvision | Python |
|---|---|---|
2.12 | 0.27 | >=3.10, <=3.14 |
2.11 | 0.26 | >=3.10, <=3.14 |
2.10 | 0.25 | >=3.10, <=3.14 |
2.9 | 0.24 | >=3.10, <=3.14 |
2.8 | 0.23 | >=3.9, <=3.13 |
2.7 | 0.22 | >=3.9, <=3.13 |
2.6 | 0.21 | >=3.9, <=3.12 |
Verify Your Installation
After installing, run the following to confirm both packages are importable and report the expected versions: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 only | https://download.pytorch.org/whl/cpu |
| CUDA 12.6 | https://download.pytorch.org/whl/cu126 |
| CUDA 12.8 | https://download.pytorch.org/whl/cu128 |
| ROCm 6.2 | https://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: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’storchvision.io module can use native C++ codecs for significantly faster image reading and writing when the following libraries are present at build time:
| Library | Purpose | Install (conda) |
|---|---|---|
libpng | Native PNG encode / decode | conda install libpng -c pytorch |
libjpeg-turbo | Fast JPEG encode / decode (SIMD) | conda install libjpeg-turbo -c pytorch |
libwebp | WebP encode / decode | conda install libwebp -c pytorch |
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 fasteraccimage backend (Intel IPP) at runtime:
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:PyAV wraps the FFmpeg libraries. For GPU-accelerated video decoding, ensure that your FFmpeg build was compiled with the appropriate hardware acceleration flags.