tensorflow: Golang Tensorflow v2.2.0 fails install

System information

  • OS Platform and Distribution (Macos catalina 10.15.4):
  • Mobile device (e.g. iPhone 8, Pixel 2, Samsung Galaxy) if the issue happens on mobile device:
  • TensorFlow installed from (source or binary):
  • TensorFlow version:
  • Python version:
  • Installed using virtualenv? pip? conda?:
  • Bazel version (if compiling from source):
  • GCC/Compiler version (if compiling from source):
  • CUDA/cuDNN version:
  • GPU model and memory:

Describe the problem

Provide the exact sequence of commands / steps that you executed before running into the problem

Following https://github.com/tensorflow/tensorflow/blob/master/tensorflow/go/README.mdhttps://github.com/tensorflow/tensorflow/blob/master/tensorflow/go/README.md

go generate github.com/tensorflow/tensorflow/tensorflow/go/op fails with failed to process "api_def_VarHandleOp.pbtxt": Attribute allowed_devices not defined in base api for VarHandleOp exit status 1 go/src/github.com/tensorflow/tensorflow/tensorflow/go/op/generate.go:18: running "go": exit status 1

go test github.com/tensorflow/tensorflow/tensorflow/go passes

building or running go code using tensorflow then proceeds to fail with the following output go: finding github.com/tensorflow/tensorflow/tensorflow/go/core/core_protos_go_proto latest go: finding github.com/tensorflow/tensorflow/tensorflow/go/core latest go: finding github.com/tensorflow/tensorflow/tensorflow/go latest go: finding github.com/tensorflow/tensorflow/tensorflow latest build command-line-arguments: cannot load github.com/tensorflow/tensorflow/tensorflow/go/core/core_protos_go_proto: cannot find module providing package github.com/tensorflow/tensorflow/tensorflow/go/core/core_protos_go_proto

the code run is the example that prints tf library version from https://www.tensorflow.org/install/lang_go

Any other info / logs Include any logs or source code that would be helpful to diagnose the problem. If including tracebacks, please include the full traceback. Large logs and files should be attached.

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Reactions: 3
  • Comments: 15 (3 by maintainers)

Most upvoted comments

@JacobSMoller Yeah, go get doesn’t work for now. I made a pull request to fix it, but there were some objections to supporting both the bazel and generated protobufs to make it work.

For that error: it occurs when there’s a version mismatch between libtensorflow.so and the TF ops in the source code. See my command above for building libtensorflow.so.

@jhseu alright thanks 😃

So no road map for having a go gettable Tensorflow isntallation 😃?

@ConverJens Sorry didn’t get a notification for you writing me.

Yes not a nice solution. But i did make it work…

Here is a public bucket with working libtensorflow 2.2 for unix and osx (If you haven’t got them already)

https://console.cloud.google.com/storage/browser/vml-tf-lib?forceOnBucketsSortingFiltering=false&project=dev-vml-cm

The next step is the not so nice step…

`FROM golang:1.13 AS builder

ARG GO_MOD_TF_PATH=/go/pkg/mod/github.com/tensorflow/tensorflow@v2.2.0+incompatible/tensorflow/go ARG GO_SRC_TF_PATH=/go/src/github.com/tensorflow/tensorflow/tensorflow/go/vendor/github.com/tensorflow/tensorflow/tensorflow/go/core/

WORKDIR /build-lib RUN apt-get update && apt-get install -y --no-install-recommends ca-certificates autoconf automake libtool curl make g++ unzip curl

RUN wget https://storage.googleapis.com/pub/gsutil.tar.gz && tar xfz gsutil.tar.gz -C $HOME && rm gsutil.tar.gz ENV PATH ${PATH}:/root/gsutil

RUN wget https://github.com/protocolbuffers/protobuf/releases/download/v3.11.4/protoc-3.11.4-linux-x86_64.zip RUN unzip -o protoc-3.11.4-linux-x86_64.zip -d /usr/local bin/protoc RUN unzip -o protoc-3.11.4-linux-x86_64.zip -d /usr/local ‘include/*’ RUN rm protoc-3.11.4-linux-x86_64.zip

RUN gsutil cp gs://vml-tf-lib/libtensorflow-unix.tar.gz . RUN tar -C /usr/local -xzf libtensorflow-unix.tar.gz RUN ldconfig RUN rm libtensorflow-unix.tar.gz

WORKDIR /build-lib RUN go get -d github.com/tensorflow/tensorflow/tensorflow/go/op; exit 0 WORKDIR /go/src/github.com/tensorflow/tensorflow/tensorflow RUN git checkout tags/v2.2.0 WORKDIR /build-lib RUN go generate github.com/tensorflow/tensorflow/tensorflow/go/op WORKDIR /app COPY go.sum /app/go.sum COPY go.mod /app/go.mod RUN go mod download RUN mkdir -p ${GO_MOD_TF_PATH}/core RUN cp -r ${GO_SRC_TF_PATH}/core_protos_go_proto ${GO_MOD_TF_PATH}/core/core_protos_go_proto RUN cp -r ${GO_SRC_TF_PATH}/framework ${GO_MOD_TF_PATH}/core/framework

RUN rm ${GO_MOD_TF_PATH}/core/core_protos_go_proto/autotuning.pb.go RUN rm ${GO_MOD_TF_PATH}/core/core_protos_go_proto/conv_autotuning.pb.go

COPY tftimer/tf.go /app/tf.go RUN go build tf.go

FROM debian:bullseye AS runner

WORKDIR /app

RUN apt-get update && apt-get install -y --no-install-recommends ca-certificates

COPY --from=builder /app/tf /app/tf COPY --from=builder /usr/local /usr/local RUN ldconfig`

So to make it work i do the

go get -d as suggested in go documentation Then do go generate then I use go mod download to get the tensorflow package. And finally copy the generated protos over from the downloaded source code to the GOPATH/pkg/mod/github.com/tensorflow/tensorflow@v2.2.0+incompatible/tensorflow/go/core

Not nice in anyway. But haven’t been able to find a better way.