Skip to content

Golang Tensorflow API cannot be build any more #23257

Closed

Description

@andreas-repp

System information

  • OS Platform and Distribution (e.g., Linux Ubuntu 16.04): Linux
  • TensorFlow version: 1.10.1, 1.11.0, 1.12.0-rc1
  • Only tested CPU version

Describe the problem
I tried to build my golang project which uses the tensorflow Go API. The CI build in Gitlab failed without a change (also old builds, which finished successfully before, cannot be build any more).

I run the following commands:

curl --silent -L "https://storage.googleapis.com/tensorflow/libtensorflow/libtensorflow-cpu-linux-x86_64-1.12.0-rc1.tar.gz" | tar -C /usr/local -xz
ldconfig
go get github.com/tensorflow/tensorflow/tensorflow/go

Then I receive the following error:

# github.com/tensorflow/tensorflow/tensorflow/go
/tmp/go-build813894416/b001/_x003.o: In function `_cgo_691d94bb61b7_Cfunc_TF_ImportGraphDefOptionsSetDefaultDevice':
/tmp/go-build/cgo-gcc-prolog:198: undefined reference to `TF_ImportGraphDefOptionsSetDefaultDevice'
collect2: error: ld returned 1 exit status

This did not happend before with the exact same commands. It also happens if I use other versions of the C library. Therefore I assume that the tensorflow Go API is broken in the current master.

Activity

  1. self-assigned this
    on Oct 26, 2018
  2. arushijain commented on Oct 26, 2018

    @arushijain

    Just to give more information on this

    I'm having the same issue building tensorflow GO API. I first tried it on my macOS, to receive the following error

    
    github.com/tensorflow/tensorflow/tensorflow/go
    # github.com/tensorflow/tensorflow/tensorflow/go
    Undefined symbols for architecture x86_64:
      "_TF_ImportGraphDefOptionsSetDefaultDevice", referenced from:
          __cgo_9c811c796559_Cfunc_TF_ImportGraphDefOptionsSetDefaultDevice in _x003.o
         (maybe you meant: __cgo_9c811c796559_Cfunc_TF_ImportGraphDefOptionsSetDefaultDevice)
    ld: symbol(s) not found for architecture x86_64
    clang: error: linker command failed with exit code 1 (use -v to see invocation) 
    

    Then, in order to isolate from issues arising due to linking issues on my personal dev env, I ran the above in a docker container and got the error

    github.com/tensorflow/tensorflow (download)
    github.com/tensorflow/tensorflow/tensorflow/go
    # github.com/tensorflow/tensorflow/tensorflow/go
    /tmp/go-build042240265/b001/_x003.o: In function `_cgo_691d94bb61b7_Cfunc_TF_ImportGraphDefOptionsSetDefaultDevice':
    /tmp/go-build/cgo-gcc-prolog:198: undefined reference to `TF_ImportGraphDefOptionsSetDefaultDevice'
    collect2: error: ld returned 1 exit status
    

    Same issue, AFAICT.

  3. bearbite commented on Oct 27, 2018

    @bearbite

    Same problem here. I can not download the go package from the github. :(

    package github.com/tensorflow/tensorflow/tensorflow/go: exit status 128 package github.com/tensorflow/tensorflow/tensorflow/go/op: cannot find package "github.com/tensorflow/tensorflow/tensorflow/go/op" in any of:

  4. asimshankar commented on Oct 28, 2018

    @asimshankar
    Contributor

    @andreas-eberle @bearbite : This is because the code in the Go library for the "master" branch depends on the C library (libtensorflow.so) built from the master branch. Since the C library being used is from the 1.10/1.11/1.12 release, you'd have to checkout the corresponding branch.

    This is similar to: #14546 (comment), where you'd want to do something like:

    cd $GOPATH/src/github.com/tensorflow/tensorflow/tensorflow/go
    git checkout r1.11

    I'll keep this issue open because this seems like something that we should at least document better in the installation instructions.

  5. andreas-repp commented on Oct 29, 2018

    @andreas-repp
    ContributorAuthor

    @asimshankar: This definitely has to be documented better. When I follow the official installation instructions, I cannot build the tensorflow Go API. Maybe consider changing the installation instructions to use a dependecy management like Go Dep. With that you can easily specify the version you'd like to build.

  6. vkuznet commented on Oct 29, 2018

    @vkuznet

    I also interested to see correct set of instructions. So far everything was "trivial" we call go get and get the build. Now it seems the orchestration should be done with git, versions, branches.

  7. asimshankar commented on Oct 29, 2018

    @asimshankar
    Contributor

    To be clear, yes we want things to be easy.
    My comments abive were meant as an explanation and a suggested workaround.

    I will have to look into the appropriate fix

  8. freecaykes commented on Nov 4, 2018

    @freecaykes

    @asimshankar is it beneficial to mention this issue on this page for the mean time until the complete fix
    https://www.tensorflow.org/install/lang_go
    I was recently installing and found this issue page to be really useful

  9. tensorflowbutler commented on Nov 20, 2018

    @tensorflowbutler
    Member

    Nagging Assignee @asimshankar: It has been 15 days with no activity and this issue has an assignee. Please update the label and/or status accordingly.

  10. fardok commented on Nov 21, 2018

    @fardok

    have the same problem installing go

    go test github.com/tensorflow/tensorflow/tensorflow/go
    github.com/tensorflow/tensorflow/tensorflow/go
    /usr/bin/ld: $WORK/b048/_x003.o: in function _cgo_9c811c796559_Cfunc_TF_ImportGraphDefOptionsSetDefaultDevice': /tmp/go-build/cgo-gcc-prolog:204: undefined reference to TF_ImportGraphDefOptionsSetDefaultDevice'
    collect2: error: ld returned 1 exit status
    FAIL github.com/tensorflow/tensorflow/tensorflow/go [build failed]

  11. fardok commented on Nov 21, 2018

    @fardok

    test with old version:

    #include <stdio.h>
    #include <tensorflow/c/c_api.h>

    int main() {
    printf("Hello from TensorFlow C library version %s\n", TF_Version());
    return 0;
    }

    also return error:

    sudo gcc test.c -o hello

    /usr/bin/ld: /tmp/ccJT12Vj.o: in function main': test.c:(.text+0xa): undefined reference to TF_Version'
    collect2: error: ld returned 1 exit status

  12. fardok commented on Nov 21, 2018

    @fardok

    g++ -I/usr/local/include -L/usr/local/lib test.c -ltensorflow

    work fine 👍

  13. freemanliu commented on Dec 18, 2019

    @freemanliu

    #35133
    not exactly the same issue. But the same part is that installing tensorflow go failed when there is a update. There should be an integration test here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions