serving
serving copied to clipboard
Unable to compile Protobuf for Golang
OS Platform: MacOS 10.14.5 On TF-Serving r1.14
I've checked other closed issues regarding this topic but still not able to find a clear solution.
I tried:
protoc -I ./ -I ../tensorflow/ \ betterchen@Yangs-MacBook-Pro --go_out=plugins=grpc:$GOPATH/src/github.com/lejiskin/tf_server_be/protos \ tensorflow_serving/apis/prediction_service.proto
The generated pb makes import cycle error and is not useful at all.
Please clarify this issue.
It's better to create an official document of "How to build a Golang gRPC client for TF-Serving"
Thanks
@betterchen Its a duplicate of issue #634. But thank you for opening this thread as the issue has not been resolved. Will take a look at the issue.
@betterchen we're looking into seeing why we don't run into this problem internally and what the fix would look like. Thank you for reporting this.
Cheers @unclepeddy
I believe using protoc orthogonal to bazel is not the correct way of going about this - the correct way would be to add a go_proto_library
for every serving_proto_library
and let bazel compile golibs during build.
Something like
serving_proto_library(
name = "model_proto",
srcs = ["model.proto"],
cc_api_version = 2,
deps = [
"@protobuf_archive//:cc_wkt_protos",
],
)
go_proto_library(
name = "model_go_proto",
importpath = "github.com/tensorflow/tensorflow_serving/apis:model_proto",
proto = ":model_proto",
deps = [
"@protobuf_archive//:cc_wkt_protos", ## Needs to be the golib version of this proto
],
)
Which runs into 2 issues that I haven't been able to resolve:
- Currently, proto_library rules don't build ProtoInfo objects, which is needed by go_proto_library (even though it's not documented?)
- What if the dependent protos don't export golibs?
Hello!
Is there any workaround for this issue or we have to wait for a bugfix?
Thanks.
I wrote a script to generate TF Serving gRPC interfaces for Go, but it would be nice if we could run protoc
directly without jumping through these hoops.
Changing this to FR - TF Serving needs to expose the appropriate build target for Golang.
@mxk do you have one for TensorFlow 2? I can compile for TensorFlow 1 fine
@jose-airspace No, I haven't tried doing anything with TensorFlow 2 yet.
If anyone else runs into this issue, I found what seems to be a simple workaround (specifically on r1.15
branch)
The issue is that tensorflow_serving/apis/prediction_log.proto
needs a LogMetadata
from tensorflow_serving/core/logging.proto
, which itself needs a ModelSpec
from tensorflow_serving/apis/model.proto
. The dependency from tensorflow_serving/apis
-> tensorflow_serving/core
-> tensorflow_serving/apis
makes Go fail.
I did a grep -r "logging.proto"
to verify that it only gets imported by apis/prediction_log.proto
. This meant I could just move logging.proto
from the core/
directory into the apis/
directory and change the import in prediction_log.proto
to import it from the new location (i.e. import "tensorflow_serving/apis/logging.proto";
)
Not sure what effects this might have on any of the actual TFS code, but it seems to be fine if all you want to do is have access to the TFS protos from within GoLang
@blepfo Do you have a repo you can share on how you got tensorflow serving working with golang grpc client?
Has anybody got a recent version working with grpc and golang? None of the workarounds here seem to work anymore.
Also, its been nearly 3 years and this issue is still open :flushed:
@grantstephens
Hi, I stored required protobuf files and scripts to get proto files for TF-Serving 2.7 APIs in this repository. And I wrote a sample client code with golang for TensorFlow Serving 2.7 in this link. I hope these repositories can help you.
@grantstephens
Hi, I stored required protobuf files and scripts to get proto files for TF-Serving 2.7 APIs in this repository. And I wrote a sample client code with golang for TensorFlow Serving 2.7 in this link. I hope these repositories can help you.
Hello, I've been following your article but I haven't managed to compile tensorflow_serving for version 2.8.2 as you didn't explain how to use babel to properly compile them. Could you explain how you managed to do this?
@1dustycy,
You can find community build Golang packages for TF Serving Client here and here as mentioned in above comment.
Please let us know if this issue can be closed. Thank you!
@1dustycy,
You can find community build Golang packages for TF Serving Client here and here as mentioned in above comment.
Please let us know if this issue can be closed. Thank you!
I haven't tried to build the client for a while. But I think this issue has kept opening long enough and the quoted reply seems resolved the problem. I'm closing this. Thanks everyone.