somaticio / tensorflow.rb

tensorflow for ruby
BSD 3-Clause "New" or "Revised" License
827 stars 66 forks source link

Turn this into a Ruby gem: Simple and reliable install on Ubuntu and OSX + add to Rubygems.org #49

Open jtoy opened 8 years ago

jtoy commented 8 years ago

there are some issues with this, will list them out later

jtoy commented 8 years ago

@Arafatk so can you explain what are the issues of why it cant currently be a gem? you mentioned docker as an issue? this definitely needs to be gemified to get more people easily using it. Does the code depend on docker being around?

nethsix commented 8 years ago

@jtoy It can be easily converted into a gem, we can just do gem build tensorflow.gemspec, which gives you tensorflow-0.0.1.gem. We could then upload it to rubygems.org. It is better that one of you guys do it if you want to gem to be tied to your account on rubygems.org. However this does not solve the problem of requiring explicit dependencies namely tensorflow (more precisely the shared library), and swig to be pre-installed on the user's system, which ruby-tensorflow relies on.

This situation is pretty similar with nokogiri gem, which is a XML/HTML, etc. parser. The gem expects the user's system to have libxml2 shared library, if not the user has to install that shared library using apt (ubuntu, etc.), brew (osx), etc. (see http://stackoverflow.com/questions/6277456/nokogiri-installation-fails-libxml2-is-missing)

Thus the easiest way for someone who doesn't want to go through the entire build process is to use Docker, which has everything pre-built.

The ideal scenario is if someone build an installer for each OS, which automates the entire build process on the user's system.

arafatkatze commented 8 years ago

@nethsix Thanks for this. I think that automating the entire process would be really cool. I don't have experience with docker but, I will look into it in some time. @jtoy I am okay with uploading the gem to rubygems, if you wish and if you wish to upload it yourself, that is also cool.

nethsix commented 8 years ago

@Arafatk Using docker to play around with ruby-tensorflow is simple, just install docker on your system, and just do docker run -it nethsix/ruby-tensorflow-ubuntu:0.0.1.a /bin/bash. Since ruby-tensorflow is already built anyone can just cd /repos/ruby-tensorflow, to gain access to the pre-installed tensorflow gem. They can justrequire 'tensorflow' to start using tensorflow in their code or irb. Let me know if I can help in anyway.

riley-usagi commented 8 years ago

Docker is a bad decision for a real project on tensorflow.

It is better to take an example from nokogiri, and write a normal manual installation of additional components / libraries.

nethsix commented 8 years ago

@Arafatk, @jtoy, just to add, 'python' tackles this library dependencies with anaconda/conda which installs every scipy python libraries and their dependencies. Perhaps ruby can have something similar to anaconda which does the same for all sciruby stuff.

jtoy commented 8 years ago

@riley-usagi I agree Docker is a bad decision for getting a gem setup. On the other side, almost every time I install nokogiri, I always run into some path/libxml issue. we should probably look into how the python tensorflow package is structured. For that, all I do is "pip install tensorflow". The ruby version must be just as simple.

chrhansen commented 8 years ago

@jtoy and @riley-usagi I agree that this should be made into a proper gem and that it should install without much user intervention on main OSs, e.g. latest two versions of Ubuntu and latest two OSX or something along those lines. This was also my reason, https://github.com/somaticio/tensorflow.rb/pull/31#issuecomment-234814384, to why I wanted to do a Travis-CI build instead of relying on docker. However, a working CircleCI is better than a broken TravisCI 😄!

A solid install script that can be used both for the end-user's (those that'll use this gem) OS could probably be reused for CI (Travis or Circle) and would be my preferred. During my failed efforts to setup TravisCI, https://github.com/somaticio/tensorflow.rb/pull/31 ("enjoying" many evenings on this), I found a bunch of resources for building Tensorflow on various OSes, such as Tensorflow's own: https://github.com/tensorflow/tensorflow/tree/master/tensorflow/tools/ci_build.

However, I think an install script would be best and fastest achieved by someone with experience in this area – it's not really super AI/ML-related after all :) E.g. if we could agree on specs for an install script (I'm happy to draft these) we can add this as an issue and add it to to the 0.1.0 milestone for someone to pick up.

nethsix commented 8 years ago

@chrhansen Could you please clarify your points about using Travis vs. Docker? Without Docker wouldn't it mean rebuilding Google's tensorflow code every time we change ruby-tensorflow? And even if we use Docker in CI, nobody is forced to use Docker anywhere else.

arafatkatze commented 8 years ago

@nethsix and @chrhansen Thanks for the valuable input and all for the effort you have done for making the testing possible. This problem may seem easy at first but it was really tough. I had even put a bounty on Stackoverflow question asked by Christian but got no good response. Despite all the difficulties, its good to know that circle ci is working fine.

I think it would be nice to have easily installable gem and adding this in our milestone would be good.

chrhansen commented 8 years ago

@nethsix For me it's not really about Travis vs. Docker, but more about making a gem that installs easily and reliably – with least amount of dependencies. SotThat would be why I'd prefer not requiring users installing and running Docker before they can run Tensorflow.rb, but if the benefits (anything else than avoiding building the shared lib?) are overwhelming, for sure!

I could very well be wrong (happens a lot :-), but I'm quite sure bazel build //tensorflow:libtensorflow.so only needs to happen once (and then put in /usr/lib/). Only if we're changing the Swig interface do we need to rebuild, in which case it would still only be the last part (https://github.com/somaticio/tensorflow.rb#install-tensorflowrb) that would have to be re-run, as far as I understand. With the combined might of the contributors here, I think we should be able to create solid installer for each OS.

chrhansen commented 8 years ago

@Arafatk if you're working on the install script (we discussed that by email a few days ago), assign this issue to you so we don't risk double work and any helpers can assist you.

Here are my suggestions for what is needed to complete this issue:

jtoy commented 8 years ago

I've been swamped. I plan to work on this mid September.

-- Sent from my mobile

On Aug 28, 2016, at 1:40 PM, Christian Hansen notifications@github.com wrote:

Create install script that works reliably for Ubuntu and OSX (e.g. last two releases) Add to Rubygems.org — You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or mute the thread.

chrhansen commented 8 years ago

@jtoy Cool. You should coordinate with @Arafatk as he also was considering working at this.

cyclotron3k commented 5 years ago

I think it's worth uploading to RubyGems, if only for discoverability.

For many Rubyists looking to try TensorFlow (myself included), their first step will be to go to rubygems.org and type tensorflow into the search box.

Currently, it's very easy to overlook this gem.