tensorflow.rb

Description

This repository contains Ruby API for utilizing TensorFlow.

Linux CPU Linux GPU PIP Mac OS CPU
Build Status Not Configured Not Configured

Code Climate Join the chat at https://gitter.im/Arafatk/tensorflow.rb Inline docs

Documentation

Everything is at RubyDoc. You can also generate docs by bundle exec rake doc.

Docker

Launch:

docker run -it nethsix/ruby-tensorflow-ubuntu:0.0.1 /bin/bash -c "source /usr/local/rvm/scripts/rvm; /bin/bash"

Try:

ruby /repos/ruby-tensorflow/examples/tf_ex1.rb

Location: /repos/ruby-tensorflow/

For details, see: https://hub.docker.com/r/nethsix/ruby-tensorflow-ubuntu/

Dependencies

Explicit Install

Implicit Install (No Action Required)

Installation

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 https://github.com/tensorflow/tensorflow
cd tensorflow

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

bazel build //tensorflow:libtensorflow.so

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

# Linux
sudo cp bazel-bin/tensorflow/libtensorflow.so /usr/lib/

# OSX
sudo cp bazel-bin/tensorflow/libtensorflow.so /usr/local/lib

Install tensorflow.rb

Clone and install this Ruby API:

git clone https://github.com/Arafatk/tensorflow.rb.git
cd tensorflow.rb/ext/sciruby/tensorflow_c
ruby extconf.rb
make
make install # Creates ../lib/ruby/site_ruby/X.X.X/<arch>/tf/Tensorflow.bundle (.so Linux)
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.

License

Copyright (c) 2016, Arafat Dad Khan. somatic

All rights reserved.