Phaengris.Art hand-drawn arts, city photos, linux / dev stories

Install Torch.rb on Linux

The process is simple but not without it’s pitfalls. Here’s the instruction how it worked for me. My system is Fedora Linux 38, but I believe it should work for other Linux distros as well.

mkdir -p ~/.local/opt

Go to


  • PyTorch Build: Stable
  • Your OS: Linux
  • Package: LibTorch
  • Language: will be automatically switched to C++ / Java after you choose LibTorch as package.
  • Compute Platform: depends on your system’s abilities. If unsure, choose CPU.

In the “Run This Command field” you’ll see something like this:

Download here (Pre-cxx11 ABI):

Download here (cxx11 ABI):

You need the cxx11 ABI version.

mkdir -p ~/Downloads

wget -P ~/Downloads

unzip -d ~/.local/opt ~/Downloads/

Go to your Ruby project

bundle config build.torch-rb --with-torch-dir=/home/"$USER"/.local/opt/libtorch

bundle add torch-rb

Compiling the gem will take a while.

You may want to verify if Torch.rb is installed correctly:

bundle exec irb

irb(main):002:0> require 'torch'
=> true

irb(main):003:0>[1, 2, 3])
=> tensor([1., 2., 3.])


  • You don’t need to install Python stuff at all. In fact the Python package seems to be built with Pre-cxx11 ABI, which is not suitable for Torch.rb.