tensorflow / build

Build-related tools for TensorFlow
Apache License 2.0
278 stars 114 forks source link

a bug about protobuf when i follow the Golang Install Guide #87

Closed shixinlishixinli closed 2 years ago

shixinlishixinli commented 2 years ago

i am following the Golang install guide. i want to use tensorflow in golang. and when i try to "go generate" in "~/gopath/src/github.com/tensorflow/tensorflow/tensorflow/go/op". there are some error about protobuf

google/protobuf/any.proto: File not found. google/protobuf/duration.proto: File not found. google/protobuf/wrappers.proto: File not found. tensorflow/stream_executor/dnn.proto: Import "google/protobuf/wrappers.proto" was not found or had errors. tensorflow/stream_executor/dnn.proto:130:3: "google.protobuf.UInt64Value" is not defined. tensorflow/core/protobuf/autotuning.proto: Import "google/protobuf/any.proto" was not found or had errors. tensorflow/core/protobuf/autotuning.proto: Import "google/protobuf/duration.proto" was not found or had errors. tensorflow/core/protobuf/autotuning.proto: Import "tensorflow/stream_executor/dnn.proto" was not found or had errors. tensorflow/core/protobuf/autotuning.proto:55:7: "stream_executor.dnn.AlgorithmProto" is not defined. tensorflow/core/protobuf/autotuning.proto:77:3: "google.protobuf.Duration" is not defined. tensorflow/core/protobuf/autotuning.proto:85:5: "stream_executor.dnn.AlgorithmProto" is not defined. tensorflow/core/protobuf/autotuning.proto:92:3: "google.protobuf.Any" is not defined. ../genop/generate.go:19: running "bash": exit status 1 generate.go:17: running "go": exit status 1

how to solve this bug? i am looking forward to you help best lisa

wamuir commented 2 years ago

Your system is missing the well-known protocol buffer types, which are distributed with libprotubuf-dev for instance.

shixinlishixinli commented 2 years ago

very sorry for my carelessness。 i thought i had installed libprotubuf-dev. now this problem is solve thank you for your help. i meet another problem. when i try to run go generate, there is a error.

../genop/main.go:30:2: no required module provides package github.com/tensorflow/tensorflow/tensorflow/go/genop/internal; to add it: go get github.com/tensorflow/tensorflow/tensorflow/go/genop/internal generate.go:18: running "go": exit status 1

the internal directory has some files. lisa@lisa:~/gopath/src/github.com/tensorflow/tensorflow/tensorflow/go/genop/internal$ ls api_def_map.go genop.go genop_test.go lib.go

i try to run "go get github.com/tensorflow/tensorflow/tensorflow/go/genop/internal/" go get github.com/tensorflow/tensorflow/tensorflow/go/genop/internal: no matching versions for query "upgrade"

i don't know what need to upgrade.

i am looking forward to your help best Lisa Shi

wamuir commented 2 years ago

Can you please change your working directory to your location of the TensorFlow Go source code and then provide the output from go env?

shixinlishixinli commented 2 years ago

GO111MODULE="" GOARCH="amd64" GOBIN="/home/lisa/resource/cri/go/bin/" GOCACHE="/home/lisa/.cache/go-build" GOENV="/home/lisa/.config/go/env" GOEXE="" GOEXPERIMENT="" GOFLAGS="" GOHOSTARCH="amd64" GOHOSTOS="linux" GOINSECURE="" GOMODCACHE="/home/lisa/gopath/pkg/mod" GONOPROXY="" GONOSUMDB="" GOOS="linux" GOPATH="/home/lisa/gopath" GOPRIVATE="" GOPROXY="https://proxy.golang.org,direct" GOROOT="/home/lisa/resource/cri/go" GOSUMDB="sum.golang.org" GOTMPDIR="" GOTOOLDIR="/home/lisa/resource/cri/go/pkg/tool/linux_amd64" GOVCS="" GOVERSION="go1.17.3" GCCGO="gccgo" AR="ar" CC="gcc" CXX="g++" CGO_ENABLED="1" GOMOD="/home/lisa/gopath/src/go.mod" CGO_CFLAGS="-g -O2" CGO_CPPFLAGS="" CGO_CXXFLAGS="-g -O2" CGO_FFLAGS="-g -O2" CGO_LDFLAGS="-g -O2" PKG_CONFIG="pkg-config" GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build845291873=/tmp/go-build -gno-record-gcc-switches"

wamuir commented 2 years ago

GOMOD="/home/lisa/gopath/src/go.mod"

You'll need to initialize a go.mod at the root of the TensorFlow source code respository, which in your case should be at /home/lisa/gopath/src/github.com/tensorflow/tensorflow.

shixinlishixinli commented 2 years ago

thank you very much for your help. i can successfully go through the "Golang Install Guide "