tensorflow.rb
Description
This repository contains a Ruby API for utilizing TensorFlow.
Linux CPU |
Linux GPU PIP |
Mac OS CPU |
---|---|---|
Not Configured | Not Configured |
Documentation
Everything is at RubyDoc. You can also generate docs by bundle exec rake doc
.
Blog Posts
Installation
Install Script
I have made a make shift install script in tools directory. You are free to use it, but it still needs some work and there is a chance that you might face some issues with it and if you do face some issues, you can use the instructions below. You are welcome to make improvements to the script.
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
- Ruby >= 2.2.0
- Bazel
- TensorFlow
- Swig
Implicit dependencies (No Action Required)
- Google-Protoc gem ( for installation do
gem install google-protoc --pre
) - Protobuf
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/
sudo cp bazel-bin/tensorflow/libtensorflow_framework.so /usr/lib
# OSX
sudo cp bazel-bin/tensorflow/libtensorflow.so /usr/local/lib
sudo cp bazel-bin/tensorflow/libtensorflow_framework.so /usr/lib
export LIBRARY_PATH=$PATH:/usr/local/lib (may be required)
tensorflow.rb
Install 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/
/sciruby/Tensorflow.{bundle, so}
cd ./../../..
bundle install
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.
Tensorboard
You can run tensorboard on tensorflow.rb too. Just take a look at tensorboard.md file.
License
Copyright (c) 2016, Arafat Dad Khan. somatic
All rights reserved.
Acknowledgements
- The Ruby Science Foundation and somatic for mentoring and sponsoring the project