cjweeks / tensorflow-cmake

Integrate TensorFlow with CMake projects effortlessly
MIT License
331 stars 83 forks source link

CMake file generation for my project #43

Open OronG13 opened 5 years ago

OronG13 commented 5 years ago

Hello cjweeks, Short background: I'm interesting about an inference application development that will execute an already trained model that was previously developed using the Tensorflow APIs. The execution shall use an NVIDIA GPU accelerations capabilities based on the NVIDIA cuDNN library only without TensorRT usage at all.

The application shall be based on Tensorflow C++ interface only (no Python at all) which means that I'm interesting to perform a process like this: https://www.tensorflow.org/install/install_sources

but for C++ not for Python.

After I will have the installed Tensorflow I will want to develop my inference application using the Nsight Eclipse Edition so my expectation is that I will have a kind of *.so file (or several files) that my application will be able to compile and linkage with them.

So, I founded your tensorflow-cmake guide an saw that if I will use it I will get the tensorflow library .so file.

These are my questions:

  1. What are the reasons that the Eigen and Protobuf are required? Is the libtensorflow_all.so depends on them? Will my application linkage process will fail without them? What are the final output of their installation process? Are they *.so files too?
  2. I cannot understand why I need to work with CMake? As I desribed above my plan is to work with the Nsight Eclipse Edition which is a full IDE provided by NVIDIA. Please clarify why I need to use the CMake? Why I need CMake files if my plan is to use the Nsight? What is the meaning of My CMake modules directory?
  3. I executed all the instructions till the phase of the Eigen generation and I got stuck. Note: I needed to edit the eigen.sh file and replace the line ARCHIVE_HEADER="native.new_http_archive(\s" with ARCHIVE_HEADER="tf_http_archive(\s" (Without that change I couldn't install the eigen)

I performed the following command: ~/Desktop/DL/tensorflow/tensorflow-cmake-master$ sudo ./eigen.sh generate installed /home/ubuntu/tensorflow

And I got the following error: Finding Eigen version in /home/ubuntu/tensorflow using method 0... Finding Eigen version in /home/ubuntu/tensorflow using method 1... Finding Eigen version in /home/ubuntu/tensorflow using method 2...

Found Eigen information in /home/ubuntu/tensorflow: Eigen URL(s): https://mirror.bazel.build/bitbucket.org/eigen/eigen/get/fd6845384b86.tar.gz https://bitbucket.org/eigen/eigen/get/fd6845384b86.tar.gz Eigen URL Hash: d956415d784fa4e42b6a2a45c32556d6aec9d0a3d8ef48baee2522ab762556a9 Eigen Archive Hash: fd6845384b86

Found Eigen in /usr/local Eigen_VERSION.cmake written to . cp: '/home/ubuntu/Desktop/DL/tensorflow-cmake-master/FindEigen.cmake' and './FindEigen.cmake' are the same file Command failed - script terminated

I founded the following: https://github.com/cjweeks/tensorflow-cmake/issues/26

But unfortunately I couldn't understand it correctly, it was not clear enough for me to understand why and what I shall do.

Any advice will be grateful.

OronG13 commented 5 years ago

I succeeded to solve the question#3 above. But still I will be happy to get answers for the question#1-2 above please.

Additionally, A new problem was raised regarding to the Protobuf: Installing Locally. I changed the line HTTP_HEADER="native.http_archive(\s" with HTTP_HEADER="tf_http_archive(\s" and then performed the following command: ~/Desktop/DL/tensorflow/tensorflow-cmake-master$ sudo ./protobuf.sh install /home/ubuntu/tensorflow

And i got the following error: Making lib/libgmock.a lib/libgmock_main.a in gmock /bin/bash: line 0: cd: third_party/googletest/googletest: No such file or directory Makefile:1964: recipe for target 'check-local' failed make[2]: [check-local] Error 1 make[2]: Leaving directory '/home/ubuntu/Desktop/DL/tensorflow-cmake-master/protobuf-3.6.0' Makefile:1826: recipe for target 'check-am' failed make[1]: [check-am] Error 2 make[1]: Leaving directory '/home/ubuntu/Desktop/DL/tensorflow-cmake-master/protobuf-3.6.0' Makefile:1538: recipe for target 'check-recursive' failed make: *** [check-recursive] Error 1 Command failed - script terminated

So i checked and I really don't have the directory third_party/googletest anywhere. Is it something related to the ./configure phase that I did wrong?

Any advice will be grateful.

OronG13 commented 5 years ago

I think that I succeeded to solve the Protobuf installation error by installing it directly from here: https://github.com/google/protobuf/blob/master/src/README.md

So now I have: libtensorflow_all.so libprotobuf.so eigen headers

I created a new project using Nsight Eclipse IDE of NVIDIA. I succeeded to compile the code of the install-project main.cc but I got a lot of 'undefined reference to' linker error regarding to tensorflow namespace objects.

Am i missing an additional .so files? Should I have more .so then those that I mentioned above?

Thanks,

minmingzhao commented 5 years ago

have the exact same issue: a lot of undefined reference to tensorflow:: ... So do you have solution now? @OronG13

OronG13 commented 5 years ago

Unfortunately no. I didn't get any answer or found any solution till now. Actually, I need to build the tensorflow from sources also for Windows so I'm now working to establish it which is also very difficult too.

MatthewScholefield commented 5 years ago

Not sure it it's related but I get the same list of undefined expressions when compiling tensorflow c code using the in-source-code method.

OronG13 commented 5 years ago

Thanks for your sharing, Did you solve these undefined expressions?

MatthewScholefield commented 5 years ago

Nope :/. Still trying to figure it out.