Skip to content

Commit 08eb45b

Browse files
authored
Rework installation instructions (#1424)
1 parent 95e2728 commit 08eb45b

1 file changed

Lines changed: 63 additions & 77 deletions

File tree

README.md

Lines changed: 63 additions & 77 deletions
Original file line numberDiff line numberDiff line change
@@ -89,18 +89,12 @@ with encoder.open_file("output.mp4"):
8989
```
9090

9191
## Installing TorchCodec
92-
### Installing CPU-only TorchCodec
9392

94-
1. Install the latest stable version of PyTorch following the
95-
[official instructions](https://pytorch.org/get-started/locally/). For other
96-
versions, refer to the table below for compatibility between versions of
97-
`torch` and `torchcodec`.
98-
99-
2. Install FFmpeg, if it's not already installed. TorchCodec supports
100-
all major FFmpeg versions in [4, 8].
101-
Linux distributions usually come with FFmpeg pre-installed. You'll need
102-
FFmpeg that comes with separate shared libraries. This is especially relevant
103-
for Windows users: these are usually called the "shared" releases.
93+
1. Install FFmpeg, if it's not already installed. TorchCodec supports all major
94+
FFmpeg versions in [4, 8]. Linux distributions usually come with FFmpeg
95+
pre-installed. You'll need FFmpeg that comes with separate shared libraries.
96+
This is especially relevant for Windows users: these are usually called the
97+
"shared" releases.
10498

10599
If FFmpeg is not already installed, or you need a more recent version, an
106100
easy way to install it is to use `conda`:
@@ -111,18 +105,74 @@ with encoder.open_file("output.mp4"):
111105
conda install "ffmpeg" -c conda-forge
112106
```
113107

114-
3. Install TorchCodec:
108+
2. Install PyTorch and TorchCodec:
115109

116110
```bash
117-
pip install torchcodec --index-url=https://download.pytorch.org/whl/cpu
111+
pip install torch torchcodec
118112
```
119113

114+
That's it! On Linux x86 and aarch64, this will install CUDA-enabled wheels by
115+
default (matching the default behavior of `pip install torch`). These wheels
116+
should *still* work even if you do not have a GPU on your machine. On macOS
117+
and Windows this will install CPU-only wheels. CPU wheels are available for
118+
Linux (x86_64 and aarch64), macOS, and Windows.
119+
120+
For other versions of PyTorch, refer to the compatibility table below.
121+
122+
### CUDA support
123+
124+
CUDA-enabled wheels are installed by default on Linux. For Windows, you'll need
125+
to pass `--index-url` as described below.
126+
127+
Make sure you have a GPU with NVDEC hardware that can decode the format you
128+
want. Refer to Nvidia's GPU support matrix
129+
[here](https://developer.nvidia.com/video-encode-and-decode-gpu-support-matrix-new).
130+
131+
You will need the `libnpp` and `libnvrtc` CUDA libraries, which are usually
132+
part of the CUDA Toolkit.
133+
134+
To select a specific CUDA Toolkit version, use `--index-url`. Make sure to
135+
install the corresponding PyTorch version as well (refer to the
136+
[official instructions](https://pytorch.org/get-started/locally/)):
137+
138+
```bash
139+
# This corresponds to CUDA Toolkit version 13.0.
140+
pip install torch torchcodec --index-url=https://download.pytorch.org/whl/cu130
141+
```
142+
143+
Make sure your FFmpeg has NVDEC support:
144+
145+
```bash
146+
ffmpeg -decoders | grep -i nvidia
147+
# This should show a line like this:
148+
# V..... h264_cuvid Nvidia CUVID H264 decoder (codec h264)
149+
```
150+
151+
To check that FFmpeg libraries work with NVDEC correctly you can decode a
152+
generated test video:
153+
154+
```bash
155+
ffmpeg -hwaccel cuda -hwaccel_output_format cuda -f lavfi -i testsrc2=duration=1 -f null -
156+
```
157+
158+
### CPU-only installation
159+
160+
To install CPU-only wheels explicitly (e.g. on Linux where CUDA wheels are the
161+
default):
162+
163+
```bash
164+
pip install torchcodec --index-url=https://download.pytorch.org/whl/cpu
165+
```
166+
167+
### Compatibility
168+
120169
The following table indicates the compatibility between versions of
121170
`torchcodec`, `torch` and Python.
122171

123172
| `torchcodec` | `torch` | Python |
124173
| ------------------ | ------------------ | ------------------- |
125174
| `main` / `nightly` | `main` / `nightly` | `>=3.10`, `<=3.14` |
175+
| `0.13` | `>=2.11` | `>=3.10`, `<=3.14` |
126176
| `0.12` | `>=2.11` | `>=3.10`, `<=3.14` |
127177
| `0.11` | `2.11` | `>=3.10`, `<=3.14` |
128178
| `0.10` | `2.10` | `>=3.10`, `<=3.14` |
@@ -145,70 +195,6 @@ The following table indicates the compatibility between versions of
145195

146196
</details>
147197

148-
### Installing CUDA-enabled TorchCodec
149-
150-
First, make sure you have a GPU that has NVDEC hardware that can decode the
151-
format you want. Refer to Nvidia's GPU support matrix for more details
152-
[here](https://developer.nvidia.com/video-encode-and-decode-gpu-support-matrix-new).
153-
154-
1. Install FFmpeg with NVDEC support.
155-
TorchCodec with CUDA should work with FFmpeg versions in [4, 8].
156-
157-
If FFmpeg is not already installed, or you need a more recent version, an
158-
easy way to install it is to use `conda`:
159-
160-
```bash
161-
conda install "ffmpeg"
162-
# or
163-
conda install "ffmpeg" -c conda-forge
164-
```
165-
166-
After installing FFmpeg make sure it has NVDEC support when you list the supported
167-
decoders:
168-
169-
```bash
170-
ffmpeg -decoders | grep -i nvidia
171-
# This should show a line like this:
172-
# V..... h264_cuvid Nvidia CUVID H264 decoder (codec h264)
173-
```
174-
175-
To check that FFmpeg libraries work with NVDEC correctly you can decode a sample video:
176-
177-
```bash
178-
ffmpeg -hwaccel cuda -hwaccel_output_format cuda -i test/resources/nasa_13013.mp4 -f null -
179-
```
180-
181-
#### Linux
182-
183-
2. Install Pytorch corresponding to your CUDA Toolkit using the
184-
[official instructions](https://pytorch.org/get-started/locally/). You'll
185-
need the `libnpp` and `libnvrtc` CUDA libraries, which are usually part of
186-
the CUDA Toolkit.
187-
188-
3. Install TorchCodec
189-
190-
On Linux, `pip install torchcodec` defaults to a CUDA wheel,
191-
matching the default behavior of `pip install torch`.
192-
193-
```bash
194-
pip install torchcodec
195-
```
196-
Use `--index-url` to select a different CUDA Toolkit version:
197-
198-
```bash
199-
# This corresponds to CUDA Toolkit version 13.0. It should be the same one
200-
# you used when you installed PyTorch (If you installed PyTorch with pip).
201-
pip install torchcodec --index-url=https://download.pytorch.org/whl/cu130
202-
```
203-
204-
#### Windows
205-
206-
2. On Windows (experimental support), you'll need to rely on `conda` to install
207-
both pytorch and TorchCodec:
208-
209-
```bash
210-
conda install -c conda-forge "torchcodec=*=*cuda*"
211-
```
212198

213199
## Contributing
214200

0 commit comments

Comments
 (0)