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

Depend on tensorflow-macos on M1, to support separate install #1860

Draft
wants to merge 1 commit into
base: develop
Choose a base branch
from

Conversation

huonw
Copy link
Member

@huonw huonw commented Feb 2, 2021

Tensorflow doesn't run directly on an Apple M1 machine, either natively (arm64) or under Rosetta (x86-64). Apple has provided preview builds at https://github.com/apple/tensorflow_macos which can be manually installed, to provide the tensorflow-macos package, which is still imported as import tensorflow. If these are manually installed then, theoretically, StellarGraph should be able to run. This patch makes this more feasible, by changing the phrasing of the Tensorflow dependency to tensorflow-macos when running on (what looks like) an M1 mac. This allows installation to proceed somewhat further, as it's no longer looking for a compatible tensorflow package on PyPI.

This is a draft PR, because I haven't yet got this to work fully: OPENBLAS="$(brew --prefix openblas)" pip install -e . fails in grpcio (looks like grpc/grpc#24677):

Building wheels for collected packages: grpcio
  Building wheel for grpcio (setup.py) ... error
...
    clang -Wno-unused-result -Wsign-compare -Wunreachable-code -DNDEBUG -g -fwrapv -O3 -Wall -I/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include -I/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include -D_WIN32_WINNT=1536 -DOPENSSL_NO_ASM=1 -DGPR_BACKWARDS_COMPATIBILITY_MODE=1 -DHAVE_CONFIG_H=1 -DGRPC_ENABLE_FORK_SUPPORT=1 -DPyMODINIT_FUNC=extern "C" __attribute__((visibility ("default"))) PyObject* -DGRPC_POSIX_FORK_ALLOW_PTHREAD_ATFORK=1 -Isrc/python/grpcio -Iinclude -I. -Ithird_party/abseil-cpp -Ithird_party/address_sorting/include -Ithird_party/cares -Ithird_party/cares/cares -Ithird_party/cares/config_darwin -Ithird_party/re2 -Ithird_party/boringssl-with-bazel/src/include -Ithird_party/upb -Isrc/core/ext/upb-generated -Isrc/core/ext/upbdefs-generated -Ithird_party/zlib -I/Users/huon/.pyenv/versions/sg/include -I/Users/huon/.pyenv/versions/3.8.7/include/python3.8 -c third_party/zlib/gzlib.c -o python_build/temp.macosx-11.1-arm64-3.8/third_party/zlib/gzlib.o -stdlib=libc++ -fvisibility=hidden -fno-wrapv -fno-exceptions -pthread
    third_party/zlib/gzlib.c:252:9: error: implicit declaration of function 'lseek' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
            LSEEK(state->fd, 0, SEEK_END);  /* so gzoffset() is correct */
            ^
    third_party/zlib/gzlib.c:14:17: note: expanded from macro 'LSEEK'
    #  define LSEEK lseek
                    ^
    third_party/zlib/gzlib.c:252:9: note: did you mean 'fseek'?
    third_party/zlib/gzlib.c:14:17: note: expanded from macro 'LSEEK'
    #  define LSEEK lseek
                    ^
    /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/stdio.h:162:6: note: 'fseek' declared here
    int      fseek(FILE *, long, int);
             ^
    third_party/zlib/gzlib.c:258:24: error: implicit declaration of function 'lseek' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
            state->start = LSEEK(state->fd, 0, SEEK_CUR);
                           ^
    third_party/zlib/gzlib.c:14:17: note: expanded from macro 'LSEEK'
    #  define LSEEK lseek
                    ^
    third_party/zlib/gzlib.c:359:9: error: implicit declaration of function 'lseek' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
        if (LSEEK(state->fd, state->start, SEEK_SET) == -1)
            ^
    third_party/zlib/gzlib.c:14:17: note: expanded from macro 'LSEEK'
    #  define LSEEK lseek
                    ^
    third_party/zlib/gzlib.c:400:15: error: implicit declaration of function 'lseek' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
            ret = LSEEK(state->fd, offset - state->x.have, SEEK_CUR);
                  ^
    third_party/zlib/gzlib.c:14:17: note: expanded from macro 'LSEEK'
    #  define LSEEK lseek
                    ^
    third_party/zlib/gzlib.c:496:14: error: implicit declaration of function 'lseek' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
        offset = LSEEK(state->fd, 0, SEEK_CUR);
                 ^
    third_party/zlib/gzlib.c:14:17: note: expanded from macro 'LSEEK'
    #  define LSEEK lseek
                    ^
  5 errors generated.
...
  ----------------------------------------
  ERROR: Failed building wheel for grpcio

Fixes #1856

@lucahost
Copy link

lucahost commented Jan 9, 2023

hey @huonw the mentioned issue in GRPCIO package seems solved, do you have time to test / merge this PR?

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

Successfully merging this pull request may close these issues.

Use stellargraph with tensorflow_macos on Mac M1
2 participants