@@ -17,7 +17,7 @@ The backend supports CPU (multithreaded), [CUDA](https://pytorch.org/docs/stable
17
17
[ ` tch-rs ` ] ( https://github.com/LaurentMazare/tch-rs ) requires the C++ PyTorch library (LibTorch) to
18
18
be available on your system.
19
19
20
- By default, the CPU distribution is installed for LibTorch v2.2 .0 as required by ` tch-rs ` .
20
+ By default, the CPU distribution is installed for LibTorch v2.6 .0 as required by ` tch-rs ` .
21
21
22
22
<details >
23
23
<summary ><strong >CUDA</strong ></summary >
@@ -26,20 +26,25 @@ To install the latest compatible CUDA distribution, set the `TORCH_CUDA_VERSION`
26
26
variable before the ` tch-rs ` dependency is retrieved with ` cargo ` .
27
27
28
28
``` shell
29
- export TORCH_CUDA_VERSION=cu121
29
+ export TORCH_CUDA_VERSION=cu124
30
30
```
31
31
32
32
On Windows:
33
33
34
34
``` powershell
35
- $Env:TORCH_CUDA_VERSION = "cu121 "
35
+ $Env:TORCH_CUDA_VERSION = "cu124 "
36
36
```
37
37
38
+ > Note: ` tch ` doesn't expose the downloaded libtorch directory on Windows when using the automatic
39
+ > download feature, so the ` torch_cuda.dll ` cannot be detected properly during build. In this case,
40
+ > you can set the ` LIBTORCH ` environment variable to point to the ` libtorch/ ` folder in ` torch-sys `
41
+ > ` OUT_DIR ` (or move the downloaded lib to a different folder and point to it).
42
+
38
43
For example, running the validation sample for the first time could be done with the following
39
44
commands:
40
45
41
46
``` shell
42
- export TORCH_CUDA_VERSION=cu121
47
+ export TORCH_CUDA_VERSION=cu124
43
48
cargo run --bin cuda --release
44
49
```
45
50
@@ -88,7 +93,7 @@ platform.
88
93
First, download the LibTorch CPU distribution.
89
94
90
95
``` shell
91
- wget -O libtorch.zip https://download.pytorch.org/libtorch/cpu/libtorch-cxx11-abi-shared-with-deps-2.2 .0%2Bcpu.zip
96
+ wget -O libtorch.zip https://download.pytorch.org/libtorch/cpu/libtorch-cxx11-abi-shared-with-deps-2.6 .0%2Bcpu.zip
92
97
unzip libtorch.zip
93
98
```
94
99
@@ -108,7 +113,7 @@ export LD_LIBRARY_PATH=/absolute/path/to/libtorch/lib:$LD_LIBRARY_PATH
108
113
First, download the LibTorch CPU distribution.
109
114
110
115
``` shell
111
- wget -O libtorch.zip https://download.pytorch.org/libtorch/cpu/libtorch-macos-x86_64-2.2 .0.zip
116
+ wget -O libtorch.zip https://download.pytorch.org/libtorch/cpu/libtorch-macos-x86_64-2.6 .0.zip
112
117
unzip libtorch.zip
113
118
```
114
119
@@ -128,7 +133,7 @@ export DYLD_LIBRARY_PATH=/absolute/path/to/libtorch/lib:$DYLD_LIBRARY_PATH
128
133
First, download the LibTorch CPU distribution.
129
134
130
135
``` powershell
131
- wget https://download.pytorch.org/libtorch/cpu/libtorch-win-shared-with-deps-2.2 .0%2Bcpu.zip -OutFile libtorch.zip
136
+ wget https://download.pytorch.org/libtorch/cpu/libtorch-win-shared-with-deps-2.6 .0%2Bcpu.zip -OutFile libtorch.zip
132
137
Expand-Archive libtorch.zip
133
138
```
134
139
@@ -144,62 +149,17 @@ $Env:Path += ";/absolute/path/to/libtorch/"
144
149
145
150
#### CUDA
146
151
147
- LibTorch 2.2.0 currently includes binary distributions with CUDA 11.8 or 12.1 runtimes. The manual
148
- installation instructions are detailed below.
149
-
150
- ** CUDA 11.8**
151
-
152
- <details open >
153
- <summary ><strong >🐧 Linux</strong ></summary >
154
-
155
- First, download the LibTorch CUDA 11.8 distribution.
156
-
157
- ``` shell
158
- wget -O libtorch.zip https://download.pytorch.org/libtorch/cu118/libtorch-cxx11-abi-shared-with-deps-2.2.0%2Bcu118.zip
159
- unzip libtorch.zip
160
- ```
161
-
162
- Then, point to that installation using the ` LIBTORCH ` and ` LD_LIBRARY_PATH ` environment variables
163
- before building ` burn-tch ` or a crate which depends on it.
164
-
165
- ``` shell
166
- export LIBTORCH=/absolute/path/to/libtorch/
167
- export LD_LIBRARY_PATH=/absolute/path/to/libtorch/lib:$LD_LIBRARY_PATH
168
- ```
169
-
170
- ** Note:** make sure your CUDA installation is in your ` PATH ` and ` LD_LIBRARY_PATH ` .
171
-
172
- </details ><br >
173
-
174
- <details >
175
- <summary ><strong >🪟 Windows</strong ></summary >
176
-
177
- First, download the LibTorch CUDA 11.8 distribution.
178
-
179
- ``` powershell
180
- wget https://download.pytorch.org/libtorch/cu118/libtorch-win-shared-with-deps-2.2.0%2Bcu118.zip -OutFile libtorch.zip
181
- Expand-Archive libtorch.zip
182
- ```
183
-
184
- Then, set the ` LIBTORCH ` environment variable and append the library to your path as with the
185
- PowerShell commands below before building ` burn-tch ` or a crate which depends on it.
186
-
187
- ``` powershell
188
- $Env:LIBTORCH = "/absolute/path/to/libtorch/"
189
- $Env:Path += ";/absolute/path/to/libtorch/"
190
- ```
191
-
192
- </details ><br >
193
-
194
- ** CUDA 12.1**
152
+ LibTorch 2.6.0 currently includes binary distributions with CUDA 11.8, 12.4 or 12.6 runtimes. The
153
+ manual installation instructions are detailed below for CUDA 12.6, but can be applied to the other
154
+ CUDA versions by replacing ` cu126 ` with the corresponding version string (e.g., ` cu118 ` or ` cu124 ` ).
195
155
196
156
<details open >
197
157
<summary ><strong >🐧 Linux</strong ></summary >
198
158
199
- First, download the LibTorch CUDA 12.1 distribution.
159
+ First, download the LibTorch CUDA 12.6 distribution.
200
160
201
161
``` shell
202
- wget -O libtorch.zip https://download.pytorch.org/libtorch/cu121 /libtorch-cxx11-abi-shared-with-deps-2.2 .0%2Bcu121 .zip
162
+ wget -O libtorch.zip https://download.pytorch.org/libtorch/cu126 /libtorch-cxx11-abi-shared-with-deps-2.6 .0%2Bcu126 .zip
203
163
unzip libtorch.zip
204
164
```
205
165
@@ -218,10 +178,10 @@ export LD_LIBRARY_PATH=/absolute/path/to/libtorch/lib:$LD_LIBRARY_PATH
218
178
<details >
219
179
<summary ><strong >🪟 Windows</strong ></summary >
220
180
221
- First, download the LibTorch CUDA 12.1 distribution.
181
+ First, download the LibTorch CUDA 12.6 distribution.
222
182
223
183
``` powershell
224
- wget https://download.pytorch.org/libtorch/cu121 /libtorch-win-shared-with-deps-2.2 .0%2Bcu121 .zip -OutFile libtorch.zip
184
+ wget https://download.pytorch.org/libtorch/cu126 /libtorch-win-shared-with-deps-2.6 .0%2Bcu126 .zip -OutFile libtorch.zip
225
185
Expand-Archive libtorch.zip
226
186
```
227
187
@@ -243,13 +203,13 @@ is to use a PyTorch installation. This requires a Python installation.
243
203
_ Note: MPS acceleration is available on MacOS 12.3+._
244
204
245
205
``` shell
246
- pip install torch==2.2 .0 numpy==1.26.4 setuptools
206
+ pip install torch==2.6 .0 numpy==1.26.4 setuptools
247
207
export LIBTORCH_USE_PYTORCH=1
248
208
export DYLD_LIBRARY_PATH=/path/to/pytorch/lib:$DYLD_LIBRARY_PATH
249
209
```
250
210
251
- ** Note:** if ` venv ` is used, it should be activated during coding and building,
252
- or the compiler may not work properly.
211
+ ** Note:** if ` venv ` is used, it should be activated during coding and building, or the compiler may
212
+ not work properly.
253
213
254
214
## Example Usage
255
215
@@ -263,7 +223,8 @@ For a more complete example using the `tch` backend, take a loot at the
263
223
264
224
Try ` .cargo/config.toml ` ([ cargo book] ( https://doc.rust-lang.org/cargo/reference/config.html#env ) ).
265
225
266
- Instead of setting the environments in your shell, you can manually add them to your ` .cargo/config.toml ` :
226
+ Instead of setting the environments in your shell, you can manually add them to your
227
+ ` .cargo/config.toml ` :
267
228
268
229
``` toml
269
230
[env ]
@@ -281,4 +242,5 @@ LD_LIBRARY_PATH = "/absolute/path/to/libtorch/lib:$LD_LIBRARY_PATH"
281
242
LIBTORCH = "/absolute/path/to/libtorch/libtorch"
282
243
EOF
283
244
```
245
+
284
246
This will automatically include the old ` LD_LIBRARY_PATH ` value in the new one.
0 commit comments