Rust bindings for the C++ API of PyTorch, providing thin wrappers around libtorch.
tch-rs is a Rust crate that provides thin, low-level bindings to the C++ API of PyTorch (libtorch). It enables Rust developers to leverage PyTorch's tensor operations, automatic differentiation, and neural network capabilities, allowing for the creation of idiomatic Rust libraries on top of PyTorch's machine learning ecosystem.
Rust developers who need to integrate PyTorch's machine learning functionalities into their applications, such as those building neural networks, training models, or deploying pre-trained models in Rust environments.
Developers choose tch-rs because it offers direct, performance-oriented access to PyTorch's C++ API from Rust, maintaining compatibility and enabling safe, efficient machine learning workflows without sacrificing the benefits of Rust's type safety and memory management.
Rust bindings for the C++ api of PyTorch.
Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.
Provides thin wrappers to PyTorch's C++ API, enabling tensor operations, automatic differentiation, and neural network building, as shown in the MNIST training example.
Combines Rust's memory safety with PyTorch's optimized backend, allowing efficient model training and inference without sacrificing reliability, leveraging libtorch's performance.
Includes utilities to load and run models like ResNet with extracted weights, and supports SafeTensors for secure, zero-copy imports from PyTorch, as detailed in the examples.
Comes with diverse examples for tasks such as MNIST classification, style transfer, and reinforcement learning, facilitating quick adoption and experimentation.
Requires manual installation of libtorch with environment variables and platform-specific steps, which can be error-prone and cumbersome, especially on Windows or without system-wide libtorch.
Stays close to the C++ API, making it less idiomatic for Rust developers and requiring familiarity with PyTorch concepts, as admitted in the project philosophy.
While documentation exists, it's less extensive than PyTorch's Python docs, and the Rust ML community is smaller, leading to fewer third-party resources and support.
Dependent on specific libtorch versions (e.g., v2.11.0), with noted ABI incompatibilities on Windows and challenges with MinGW, risking segfaults or build failures.