How do you compile the TF Serving .proto files?

I’m trying to compile all of the .proto files from TF Serving so that I can create a gRPC client to communicate with a model I have served by TF Serving.

I can’t find any good way to do this - I don’t think anyone else can either:

There are a number of hacked-together scripts that no longer work.

Does anyone have a better way of compiling all of these protobuf definitions?

I’ve personally been trying to compile manually with protoc:

[joe@dev serving]$ protoc --go-grpc_out=./gen --go-grpc_opt=paths=source_relative tensorflow_serving/apis/*.proto
protoc-gen-go-grpc: unable to determine Go import path for "tensorflow_serving/apis/input.proto"

Please specify either:
        • a "go_package" option in the .proto source file, or
        • a "M" argument on the command line.

See for more information.

This seems to be because the .proto files in TF Serving don’t have an option go_package assigned.

Any help on this issue would be greatly appreciated.

if anyone else is stuck, you can try and use Buf’s managed mode to build the (edited by moderator)TF serving proto files:


Make sure you have installed the Buf CLI (See documentation)

  1. Clone the Buf managed mode example repo buf-examples/managed-mode at main · bufbuild/buf-examples · GitHub (make sure you’re inside the managed-mode directory)
  2. Put tensorflow_serving inside managed-mode/ serving/tensorflow_serving at master · tensorflow/serving · GitHub
  3. Put tensorflow https[:]//github[.]com/tensorflow/tensorflow in there as well
  4. Run buf generate
  5. You should find all your proto files in gen/