Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Building the Tensorflow binding on MacOS. #2

Open
charlie5 opened this issue Jan 14, 2023 · 7 comments
Open

Building the Tensorflow binding on MacOS. #2

charlie5 opened this issue Jan 14, 2023 · 7 comments

Comments

@charlie5
Copy link
Owner

charlie5 commented Jan 14, 2023

The following problems/adjustments were reported by Roger Mc on c.l.a ...

  1. I removed "-lpthread" from Builder sections of the project (gpr) files due to builder complaint.

  2. In tensorflow_wrap.c I needed to change
    #include <tensorflow/tensorflow/c/c_api.h>
    to
    #include <tensorflow/c/c_api.h>

  3. In tensorflow.gpr I needed to change
    with "swig";
    to
    with "../../../tier-0/swig/library/swig.gpr";

  4. In tensorflow.gpr I added my path to tensorflow/c/c_api.h to the Source_Dirs
    In my case: "/usr/local/Cellar/libtensorflow/2.11.0/include"

  5. Not sure whether or not I caused this diff statement for the gpr files:
    -end hello_TF;
    \ No newline at end of file
    +end Hello_TF;

  6. In hello_tf.gpr:

Change ...

with
"tensorflow",
"swig";

to ...

with "../../../library/tensorflow.gpr";

Presumably 'with' of "swig" is redundant, as it's imported by tensorflow.gpr

@charlie5
Copy link
Owner Author

charlie5 commented Jan 14, 2023

Problems 1, 2 and 5 have been fixed.

Problem 3:

I don't understand why a relative path to 'swig.gpr' is needed, since the swig library folder should have been added to GPR_PROJECT_PATH when "source $CBOUND/cbound-gpr_paths.sh" is done in '.bashrc' (or equivalent) as per the 'Install' notes in the 'README.md'.

Problem 4:

I can probably fix this with as OS scenario variable. Will try it tomorrow.

Problem 6:

For the relative path to 'tensorflow.gpr', the same applies as in Problem 3.

The 'with' of "swig" is indeed redundant and has been removed.

Thanks for reporting these Roger.

@rogermc2
Copy link

rogermc2 commented Jan 14, 2023

Of course!
Please ignore Problems 3 and 6.

@charlie5
Copy link
Owner Author

@rogermc2

How was tensorflow installed on your system ? Via a package manager ?

I need to know if the 'c_api.h' will be installed in "/usr/local/Cellar/libtensorflow/2.11.0/include" as a 'standard' location on other peoples MacOS systems.

@rogermc2
Copy link

rogermc2 commented Jan 14, 2023

I think this is quite problematic.
On my Ventura computer, tensorflow was installed using the Homebrew package manager.
As this installation works I suspect that this is the most likely and, possibly, the best method.
On High Sierra I could only install tensorflow with pip as brew installation failed.
However, tensorflow installation with pip doesn't include the tensorflow library, so linking fails with undefined symbols.
Also note that Mac OSX High Sierra is "no longer supported" by Apple and Homebrew.

@rogermc2
Copy link

I'm wondering if a cBound solution is possible for Python3?
I had this idea because I'm currently using the Python C API extensively.

@rogermc2
Copy link

I don't really understand why Problem 4 occurs as /usr/local/include has a tensorflow link to /Cellar/libtensorflow/2.11.0/include/tensorflow

@charlie5
Copy link
Owner Author

Didn't get much of a chance to look at this today, sorry.

I have d/l'ed and am installing macOS onto a qemu box, so should be able to experiment a bit tomorrow.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants