Open-Awesome
CategoriesAlternativesStacksSelf-HostedExplore
Open-Awesome

© 2026 Open-Awesome. Curated for the developer elite.

TermsPrivacyAboutGitHubRSS
  1. Home
  2. ML with Ruby
  3. torch-rb

torch-rb

NOASSERTIONRuby

A Ruby deep learning library powered by LibTorch, providing a PyTorch-like API for Ruby developers.

GitHubGitHub
840 stars38 forks0 contributors

What is torch-rb?

Torch.rb is a deep learning library for Ruby that provides a PyTorch-like API, powered by LibTorch. It allows Ruby developers to perform tensor computations, build neural networks, and leverage GPU acceleration for machine learning tasks directly within Ruby applications.

Target Audience

Ruby developers and data scientists who want to implement deep learning models without leaving the Ruby ecosystem, especially those familiar with PyTorch's API.

Value Proposition

It offers a seamless bridge between Ruby and PyTorch's performance, with an idiomatic Ruby API, GPU support, and compatibility with PyTorch tutorials and models.

Overview

Deep learning for Ruby, powered by LibTorch

Use Cases

Best For

  • Implementing neural networks in Ruby applications
  • Converting PyTorch models and tutorials to Ruby
  • Performing tensor computations with GPU acceleration in Ruby
  • Building deep learning prototypes quickly within Ruby environments
  • Integrating machine learning models into Ruby on Rails projects
  • Educational purposes for learning deep learning concepts in Ruby

Not Ideal For

  • Windows-based development environments, as Torch.rb explicitly does not support Windows platforms
  • Teams requiring access to a vast library of pre-trained models or cutting-edge research implementations, due to Ruby's smaller deep learning ecosystem compared to Python
  • Projects with strict deployment timelines and no existing Ruby infrastructure, where Python's PyTorch offers more mature tooling and community support
  • Applications needing straightforward, no-compilation installation, since Torch.rb requires manual LibTorch download and extension compilation

Pros & Cons

Pros

High-Performance Backend

Leverages LibTorch, PyTorch's C++ backend, for efficient tensor computations and GPU acceleration, matching PyTorch's core performance.

Ruby-Idiomatic API

Adapts PyTorch's API to Ruby conventions, using methods like add! for in-place operations and tensor? for boolean checks, making it intuitive for Ruby developers.

GPU Acceleration Support

Supports CUDA on Linux and Metal Performance Shaders on Apple silicon, enabling faster training on compatible hardware, as detailed in the performance section.

Seamless Numo Integration

Allows easy conversion between Torch tensors and Numo arrays with x.numo and Torch.from_numo, facilitating integration with Ruby's scientific computing stack.

PyTorch Tutorial Compatibility

Users can follow PyTorch tutorials and convert code to Ruby, as noted in the API section, reducing the learning curve for those familiar with PyTorch.

Cons

Platform Limitations

Excludes Windows support entirely, limiting its use to Linux and Mac environments, which is a significant barrier for some development teams.

Complex Installation Process

Requires manual download of LibTorch and compilation of extensions, taking 5-10 minutes and potentially causing setup errors, as highlighted in the installation instructions.

Limited Ecosystem Maturity

While companion gems exist, the overall deep learning ecosystem in Ruby is smaller, with fewer community resources and pre-trained models compared to Python's PyTorch.

Interoperability Hurdles

Loading models saved in Python requires extra steps to convert parameters due to bugs in LibTorch, adding friction to cross-language workflows, as admitted in the saving and loading section.

Frequently Asked Questions

Quick Stats

Stars840
Forks38
Contributors0
Open Issues1
Last commit6 days ago
CreatedSince 2019

Tags

#deep-learning#gpu-acceleration#neural-networks#ruby-gem#libtorch#tensor-computation#machine-learning#pytorch#autograd

Built With

R
Ruby
M
Metal Performance Shaders
C
CUDA
l
libtorch

Included in

ML with Ruby2.2k
Auto-fetched 1 day ago

Related Projects

tensorflow.rbtensorflow.rb

tensorflow for ruby

Stars832
Forks61
Last commit4 years ago
tensor_streamtensor_stream

A ground-up and standalone reimplementation of TensorFlow for ruby. Comes with a pure ruby and OpenCL opcode evaluator

Stars504
Forks16
Last commit5 years ago
red-chainerred-chainer

A flexible framework for neural network for Ruby

Stars103
Forks17
Last commit4 years ago
mxnetmxnet

MXNet binding for Ruby

Stars48
Forks9
Last commit5 years ago
Community-curated · Updated weekly · 100% open source

Found a gem we're missing?

Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.

Submit a projectStar on GitHub