2

So I installed Tensorflow as described here. One of the answers mentions that the project must be within the cloned local TensorFlow repo. Is there a way to have the project outside the repo?

Seanny123
  • 8,776
  • 13
  • 68
  • 124
Alperen AYDIN
  • 547
  • 1
  • 6
  • 17
  • Maybe something like this can help - run configure with this key : ./configure --prefix=/somewhere/else/than/usr/local – tty6 Aug 15 '16 at 08:55
  • I am sorry. I am not sure what you mean by somewhere else. Do you mean the directory of my project? – Alperen AYDIN Aug 15 '16 at 17:40

3 Answers3

0

As far as I know, there is no official way to build your code outside of the TF repo. You can, however, use tensorflow_cc project, that builds and installs TF C++ library for you and provides convenient CMake targets with all the necessary headers and link parameters.

Floop
  • 451
  • 4
  • 10
0

Yes there is, you would just need to do the following:

  1. Clone the tensorflow repository

  2. ./configure to your linking (enable CUDA, etc.)

  3. Using bazel build build //tensorflow:libtensorflow.so and //tensorflow:libtensorflow_cc.so.

  4. Create a project of your own, outside the repository and link against the .so:s you just compiled, you would need the following options at compile/link time:

    -I/path/to/repo/tensorflow
    -L/path/to/repo/tensorflow/bazel-bin/tensorflow
    -ltensorflow_framework -ltensorflow_cc
    
  5. Your .hpp and .cpp files can now use tensorflow::Session, and other classes by including the appropriate header files:

    #include "tensorflow/core/public/session.h"
    #include "tensorflow/cc/ops/standard_ops.h"
    

You might also need (for headers generated by protobuf compiler protoc):

-I/path/to/repo/tensorflow/bazel-genfiles/

As well as to dependent libraries (e.g. it complained about nsync):

-I/path/to/repo/tensorflow/bazel-tensorflow/external/nsync/public

Hope this is helpful.

pcp
  • 134
  • 1
  • 8
0

I've successfully built tensorflow-gpu dyanmic library, with Cmake and Visual Studio 2015, and now I'm able to put the project outside the TF repo.

1.git clone -b r1.7 --single-branch https://github.com/tensorflow/tensorflow.git

2.Cmake and select options with shared library and enable-gpu

3.build tensorflow.dll and tensorflow.lib with visual studio 2015

There will be some error during building, but it's easy to fix. Leave a comment if you hope to know the details.

Giles_Chao
  • 11
  • 5