Skip to content

squidCatx/tensorflow.rb

 
 

Repository files navigation

tensorflow.rb

Description

This repository contains a 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/tensorflowrb/Lobby Inline docs

Documentation

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

Blog Posts

  1. Introductory blog post
  2. Developers blog post
  3. Image Recognition Tutorial

Installation

Docker

It's easiest to get started using the prebuilt Docker container.

Launch:

docker run --rm -it nethsix/ruby-tensorflow-ubuntu:0.0.1 /bin/bash

Test:

cd /repos/tensorflow.rb/
bundle exec rspec

Image Classification Tutorial:

cd /repos/tensorflow.rb/image/
cat README

For more details about all the fun machine-learning stuff already pre-installed, see: https://hub.docker.com/r/nethsix/ruby-tensorflow-ubuntu/

Outside of Docker

Alternatively, you can install outside of a Docker container by following the following steps.

Explicit dependencies

Implicit dependencies (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
./configure

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

bazel build -c opt //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
export LIBRARY_PATH=$PATH:/usr/local/lib (may be required)

Install tensorflow.rb

Clone and install this Ruby API:

git clone https://github.com/somaticio/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.

Install Script

I have also made a make shift install script in tools directory. You are free to use it, but it still needs some work and its best if you follow the installation procedure above or use docker. You are welcome to make improvements to the script.

License

Copyright (c) 2016, Arafat Dad Khan. somatic

All rights reserved.

Acknowledgements

About

tensorflow for ruby

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Ruby 65.3%
  • C 27.8%
  • C++ 5.9%
  • Other 1.0%