This repository contains Ruby API for utilizing TensorFlow.



All the dependencies mentioned above must be installed in your system before you proceed further.

Clone and Install TensorFlow

This package depends on the TensorFlow shared libraries, in order to compile these libraries do the following:

git clone --recurse-submodules
cd tensorflow

This command clones the repository and a few sub modules. After this you should do:

bazel build //

This command takes in the order of 10-15 minutes to run and creates a shared library. When finished, copy the newly generated shared library:

# Linux
sudo cp bazel-bin/tensorflow/ /usr/lib/

sudo cp bazel-bin/tensorflow/ /usr/local/lib

Install ruby-tensorflow

Clone and install this Ruby API:

git clone
cd ruby-tensorflow
cd ext
ruby extconf.rb
make install # Creates ../lib/ruby/site_ruby/X.X.X/<arch>/tf/Tensorflow.bundle (.so Linux)
             # Creates ${GEM_HOME}/gems/tensorflow-0.0.1/lib/tf/Tensorflow.bundle (.so with rvm)
cd ./..
bundle exec rake install

The last command is for installing the gem.

Run tests and verify install

bundle exec rake spec

This command is to run the tests.


Copyright (c) 2016, Arafat Dad Khan.

All rights reserved.