somaticio / tensorflow.rb

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

Adding Additional Namespace Internal #24

Closed arafatkatze closed 8 years ago

arafatkatze commented 8 years ago

Based on the wonderful suggestion by @zverok. I hope this works fine before merging. It would be good if you can try this.

chrhansen commented 8 years ago

@Arafatk sure! What are the specifics we should look out for? Building the project from scratch or just test that specs still run?

chrhansen commented 8 years ago

@Arafatk I've

  1. run the swig > make > make install commands
  2. run rspec – all pass except, the spring spec (#17)
  3. added a few comments, mostly regarding syntax.

Basically, the gem seems to still work like before! 😄

chrhansen commented 8 years ago

@Arafatk when I make install on OSX I get:

install: /Users/<usr>/.rvm/rubies/ruby-2.2.1/lib/ruby/site_ruby/2.2.0/x86_64-darwin14/sciruby/tensorflow: No such file or directory

I have to manually create the folder sciruby and a folder inside that, tensorflow. After that make install runs fine and I have the file /sciruby/tensorflow/internal.bundle

geoffreylitt commented 8 years ago

@chrhansen I think there's a chance this would help:

cd ext/sciruby/tensorflow_c
rm *.time

I don't fully understand the behavior, but my experience with #22 was that those files being present seemed to mess up directory creation when running install.

chrhansen commented 8 years ago

@geoffreylitt I guess my point was more that this should be part of the build script.

arafatkatze commented 8 years ago

@chrhansen Thanks a lot for pointing it out. I am getting

arafat@arafat-HP-450-Notebook-PC:~/Desktop/shop/name/tensorflow.rb/ext/sciruby/tensorflow_c$ ruby extconf.rb
creating Makefile
arafat@arafat-HP-450-Notebook-PC:~/Desktop/shop/name/tensorflow.rb/ext/sciruby/tensorflow_c$ make
compiling internal_wrap.cxx
linking shared-object sciruby/tensorflow/internal.so
arafat@arafat-HP-450-Notebook-PC:~/Desktop/shop/name/tensorflow.rb/ext/sciruby/tensorflow_c$ make install
/usr/bin/install -m 0755 internal.so /usr/share/rvm/rubies/ruby-2.2.1/lib/ruby/site_ruby/2.2.0/x86_64-linux/sciruby/tensorflow

Can you please point out a workaround for this ? I am not able to replicate this.

chrhansen commented 8 years ago

@Arafatk sorry for the late reply. If I'm the only one that gets the directory error on make install on a fresh install, then let's just leave that.

However, I just tried to replicate, i.e. removing all dirs inside .../2.2.0/x86_64-linux/ (../2.2.0/x86_64-darwin14/ for me), and then running ruby extconf.rb then make, and I'm actually getting another error in make now:

➜  tensorflow_c git:(master) ruby extconf.rb
creating Makefile
➜  tensorflow_c git:(master) make
compiling Tensorflow_wrap.cxx
linking shared-object sciruby/Tensorflow.bundle
duplicate symbol __ZN10tensorflow14TF_Run_wrapperEP10TF_SessionNSt3__16vectorINS2_12basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEENS7_IS9_EEEENS3_IP9TF_TensorNS7_ISD_EEEESB_RSF_SB_P9TF_Status in:
    Internal_wrap.o
    Tensorflow_wrap.o
duplicate symbol __ZN10tensorflow12print_tensorEP9TF_Tensor in:
    Internal_wrap.o
    Tensorflow_wrap.o
duplicate symbol __ZN10tensorflow14complex_readerEP9TF_Tensor in:
    Internal_wrap.o
    Tensorflow_wrap.o
...
...
...
duplicate symbol __ZN10tensorflow33complex_array_from_complex_vectorENSt3__16vectorINS0_7complexIdEENS0_9allocatorIS3_EEEE in:
    Internal_wrap.o
    Tensorflow_wrap.o
ld: 30 duplicate symbols for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [Tensorflow.bundle] Error 1