Top AI Repos — open-source AI, indexed and scored
Top AI Repos tracks AI repositories on GitHub and answers two different questions about each one: is it moving right now, and would you bet a product on it.
Top AI Repos tracks AI repositories on GitHub and answers two different questions about each one: is it moving right now, and would you bet a product on it.
Rust bindings for the C++ api of PyTorch.
| Date | Stars |
|---|---|
| 2026-07-24 | 5454 |
| 2026-07-25 | 5454 |
| 2026-07-28 | 5454 |
| 2026-07-30 | 5454 |
| 2026-08-06 | 5454 |
Today
— stars today
This week
— stars this week
This month
— stars this month
Momentum
0.0
growth rate 0.00%/day
# tch-rs
Rust bindings for the C++ api of PyTorch. The goal of the `tch` crate is to
provide some thin wrappers around the C++ PyTorch api (a.k.a. libtorch). It
aims at staying as close as possible to the original C++ api. More idiomatic
rust bindings could then be developed on top of this. The
[documentation](https://docs.rs/tch/) can be found on docs.rs.
[](https://github.com/LaurentMazare/tch-rs/actions)
[](https://crates.io/crates/tch)
[](https://docs.rs/tch)
[](https://deps.rs/repo/github/LaurentMazare/tch-rs)

[changelog](https://github.com/LaurentMazare/tch-rs/blob/main/CHANGELOG.md)
The code generation part for the C api on top of libtorch comes from
[ocaml-torch](https://github.com/LaurentMazare/ocaml-torch).
## Getting Started
This crate requires the C++ PyTorch library (libtorch) in version *v2.11.0* to be available on
your system. You can either:
- Use the system-wide libtorch installation (default).
- Install libtorch manually and let the build script know about it via the `LIBTORCH` environment variable.
- Use a Python PyTorch install, to do this set `LIBTORCH_USE_PYTORCH=1`.
- When a system-wide libtorch can't be found and `LIBTORCH` is not set, the
build script can download a pre-built binary version of libtorch by using
the `download-libtorch` feature. By default a CPU version is used. The
`TORCH_CUDA_VERSION` environment variable can be set to `cu117` in order to
get a pre-built binary using CUDA 11.7.
### System-wide Libtorch
On linux platforms, the build script will look for a system-wide libtorch
library in `/usr/lib/libtorch.so`.
### Python PyTorch Install
If the `LIBTORCH_USE_PYTORCH` environment variable is set, the active python
interpreter is called to retrieve information about the torch python package.
This version is then linked against.
### Libtorch Manual Install
- Get `libtorch` from the
[PyTorch website download section](https://pytorch.org/get-started/locally/) and extract
the content of the zip file.
- For Linux and macOS users, add the following to your `.bashrc` or equivalent, where `/path/to/libtorch`
is the path to the directory that was created when unzipping the file.
```bash
export LIBTORCH=/path/to/libtorch
```
The header files location can also be specified separately from the shared library via
the following:
```bash
# LIBTORCH_INCLUDE must contain `include` directory.
export LIBTORCH_INCLUDE=/path/to/libtorch/
# LIBTORCH_LIB must contain `lib` directory.
export LIBTORCH_LIB=/path/to/libtorch/
```
- For Windows users, assuming that `X:\path\to\libtorch` is the unzipped libtorch directory.
- Navigate to Control Panel -> View advanced system settings -> Environment variables.
- Create the `LIBTORCH` variable and set it to `X:\path\to\libtorch`.
- Append `X:\path\to\libtorch\lib` to the `Path` variable.
If you prefer to temporarily set environment variables, in PowerShell you can run
```powershell
$Env:LIBTORCH = "X:\path\to\libtorch"
$Env:Path += ";X:\path\to\libtorch\lib"
```
- You should now be able to run some examples, e.g. `cargo run --example basics`.
### Windows Specific Notes
As per [the pytorch docs](https://pytorch.org/cppdocs/installing.html) the Windows debug and release builds are not ABI-compatible. This could lead to some segfaults if the incorrect version of libtorch is used.
It is recommended to use the MSVC Rust toolchain (e.g. by installing `stable-x86_64-pc-windows-msvc` via rustup) rather than a MinGW based one as PyTorch has compatibilities issues with MinGW.
### Static Linking
When setting environment variable `LIBTORCH_STATIC=1`, `libtorch` is statically
linked rather than using the dynamicExcerpt of 14,941 characters
Read on GitHubLaurent Mazare · France
799
22
Daniël de Kok · @huggingface · Netherlands
14
14
4
Maarten de Vries · Netherlands
4
3
3
3
Jochen Görtler · Self-employed · Germany
3
3
vcarpani · @fizyr
3
3
William Myers · @withmartian · United States
3
A.V. · Latvia
2
simlay · Unclear
2
mosh · Japan
2
2
Ehsan M. Kermani · @modular · Canada
2
2
Would you bet a product on this? Bounded 0–100 and slow moving.
matched fp:7159151d68dde53f, topic:deep-learning, topic:neural-network, topic:pytorch