Skip to content

Commit

Permalink
client updates and additions
Browse files Browse the repository at this point in the history
update bazel and build dependencies

rename python client bazel package and update wheel scripts

add c++ and go client library support

minor readme updates
  • Loading branch information
emacski committed Mar 19, 2021
1 parent 3f77d7a commit a021aa0
Show file tree
Hide file tree
Showing 17 changed files with 222 additions and 108 deletions.
8 changes: 3 additions & 5 deletions .bazelrc
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
# upstream tensorflow/serving version
build --embed_label=2.2.0

common --experimental_repo_remote_exec
build --embed_label=2.3.0

build --verbose_failures
# enable proper toolchain resolution for cc rules
Expand All @@ -14,10 +12,10 @@ build --copt=-O3
build:release --copt=-w
build:release --output_filter=DONT_MATCH_ANYTHING

# grpc build options
build --define=grpc_no_ares=true
# protobuf / grpc build options
build --define=use_fast_cpp_protos=true
build --define=allow_oversize_protos=true
build --define=grpc_no_ares=true

# build with shared gnu libstdc++ instead of static libc++
build:gnulibcpp --@com_github_emacski_bazeltools//toolchain/cpp/clang:use_libcpp="libstdc++"
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ jobs:
- name: Bazel Build
run: |
docker run --rm -v ${HOME}/.cache/bazel:/root/.cache/bazel --entrypoint chown emacski/tensorflow-serving-arm-client:latest-devel -R root:root /root/.cache/bazel
tools/ci/bazel.sh run --spawn_strategy=local --config=release //python/wheel:build_pure
tools/ci/bazel.sh run --spawn_strategy=local --config=release --config=linux_amd64 //python/wheel:build_platform
tools/ci/bazel.sh run --spawn_strategy=local --config=release --config=linux_arm64 //python/wheel:build_platform
tools/ci/bazel.sh run --spawn_strategy=local --config=release --config=linux_arm //python/wheel:build_platform
tools/ci/bazel.sh run //py/wheel:build_pure --config=release
tools/ci/bazel.sh run //py/wheel:build_platform --config=linux_amd64 --config=release
tools/ci/bazel.sh run //py/wheel:build_platform --config=linux_arm64 --config=release
tools/ci/bazel.sh run //py/wheel:build_platform --config=linux_arm --config=release
sudo chown -R $(whoami):$(whoami) ${HOME}/.cache/bazel
8 changes: 4 additions & 4 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,10 @@ jobs:
- name: Bazel Build
run: |
docker run --rm -v ${HOME}/.cache/bazel:/root/.cache/bazel --entrypoint chown emacski/tensorflow-serving-arm-client:latest-devel -R root:root /root/.cache/bazel
tools/ci/bazel.sh run --spawn_strategy=local --config=release //python/wheel:build_pure
tools/ci/bazel.sh run --spawn_strategy=local --config=release --config=linux_amd64 //python/wheel:build_platform
tools/ci/bazel.sh run --spawn_strategy=local --config=release --config=linux_arm64 //python/wheel:build_platform
tools/ci/bazel.sh run --spawn_strategy=local --config=release --config=linux_arm //python/wheel:build_platform
tools/ci/bazel.sh run //py/wheel:build_pure --config=release
tools/ci/bazel.sh run //py/wheel:build_platform --config=linux_amd64 --config=release
tools/ci/bazel.sh run //py/wheel:build_platform --config=linux_arm64 --config=release
tools/ci/bazel.sh run //py/wheel:build_platform --config=linux_arm --config=release
sudo chown -R $(whoami):$(whoami) ${HOME}/.cache/bazel
- name: Create Release
id: create_release
Expand Down
11 changes: 0 additions & 11 deletions BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@
# See the License for the specific language governing permissions and
# limitations under the License.

load("@rules_python//python:defs.bzl", "py_library")

package(default_visibility = ["//visibility:public"])

platform(
Expand All @@ -39,12 +37,3 @@ platform(
"@platforms//cpu:arm",
],
)

# python client

py_library(
name = "python",
imports = ["python"],
srcs_version = "PY3",
deps = ["//python:grpc"],
)
59 changes: 40 additions & 19 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,31 +5,52 @@ Tensorflow Serving ARM Client
**EXPERIMENTAL (anything can change)**

A project for cross building [tensorflow/serving](https://github.com/tensorflow/serving)
grpc api clients targeting popular arm architectures from an x86_64 host.
Additionally, this includes an experimental multi-arch standalone python3 client
(it doesn't depend on the core tensorflow python package).
standalone grpc api clients targeting popular arm architectures from an x86_64 host.
Currently, client libraries can be cross-built for c++, python and go targeting
`linux_amd64`, `linux_arm64` and `linux_arm`.

## Python3 Client
## Project Artifacts
### Python3 Client Library (Wheels)

### Wheels
Currently, platform specific wheels are published for CPython 3.7 on
`linux_amd64`, `linux_arm64` and `linux_arm`. These wheels are full self-contained
grpc client libs and include the `tensorflow_serving`, (protobuf only) `tensorflow`,
`grpcio` and `protobuf` py packages with corresponding extensions where applicable
(no compiling or dev-tools required on the install host).

A pure python3 wheel is maintained that depends on `grpcio` and `protobuf`
python packages.
Additionally, a pure python3 wheel is published that includes the `tensorflow_serving`,
(protobuf only) `tensorflow` packages and depends on external `grpcio` and
`protobuf` python packages.

Currently, platform specific wheels are maintained for CPython 3.7 on
`linux_amd64`, `linux_arm64` and `linux_arm`. These wheels are full
self-contained grpc client libs and include the `tensorflow_serving`,
`tensorflow`, `grpcio` and `protobuf`, python packages with corresponding
compiled extensions where applicable.

**Install with `pip`**
**Install Wheels with `pip`**
```sh
# on linux_amd64 python 3.7
pip install https://github.com/emacski/tensorflow-serving-arm-client/releases/download/2.2.0/tensorflow_serving_arm_client-2.2.0-cp37-none-manylinux2014_x86_64.whl
pip install https://github.com/emacski/tensorflow-serving-arm-client/releases/download/2.3.0/tensorflow_serving_arm_client-2.3.0-cp37-none-manylinux2014_x86_64.whl
# on linux_arm64 python 3.7
pip install https://github.com/emacski/tensorflow-serving-arm-client/releases/download/2.2.0/tensorflow_serving_arm_client-2.2.0-cp37-none-manylinux2014_aarch64.whl
pip install https://github.com/emacski/tensorflow-serving-arm-client/releases/download/2.3.0/tensorflow_serving_arm_client-2.3.0-cp37-none-manylinux2014_aarch64.whl
# on linux_arm python 3.7
pip install https://github.com/emacski/tensorflow-serving-arm-client/releases/download/2.2.0/tensorflow_serving_arm_client-2.2.0-cp37-none-manylinux2014_armv7l.whl
# pure python 3 (depends on grpcio and protobuf)
pip install https://github.com/emacski/tensorflow-serving-arm-client/releases/download/2.2.0/tensorflow_serving_arm_client-2.2.0-py3-none-any.whl
pip install https://github.com/emacski/tensorflow-serving-arm-client/releases/download/2.3.0/tensorflow_serving_arm_client-2.3.0-cp37-none-manylinux2014_armv7l.whl
# pure python 3 (will also install grpcio and protobuf pypi packages)
pip install https://github.com/emacski/tensorflow-serving-arm-client/releases/download/2.3.0/tensorflow_serving_arm_client-2.3.0-py3-none-any.whl
```

**Building Wheels From Source**
```sh
git clone [email protected]:emacski/tensorflow-serving-arm-client.git
cd tensorflow-serving-arm-client

# Build Environment
docker run --rm -ti \
-w /tensorflow-serving-arm-client \
-v $PWD:/tensorflow-serving-arm-client \
emacski/tensorflow-serving:latest-devel /bin/bash
```
By default, wheel artifacts will be output to the workspace root
```sh
# pure python
bazel run //py/wheel:build_pure
# with extension
bazel run //py/wheel:build_platform --config=linux_amd64
bazel run //py/wheel:build_platform --config=linux_arm64
bazel run //py/wheel:build_platform --config=linux_arm
```
91 changes: 51 additions & 40 deletions WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,15 @@ load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")

http_archive(
name = "com_github_emacski_bazeltools",
sha256 = "6f3c9b725b2222ea16e6eabfb8f2a9ec267567f0c05c9c4f36cbd641cd02ff39",
strip_prefix = "bazel-tools-74b14ec277cbc79c328142c561d1edd69e05d3b4",
urls = ["https://github.com/emacski/bazel-tools/archive/74b14ec277cbc79c328142c561d1edd69e05d3b4.tar.gz"],
sha256 = "ac040d00f7f00c9947d61c7b8970a877d907c92e088966c24a0eaeeba5551b19",
strip_prefix = "bazel-tools-250e4a98908fa0c6631ebccdeae930a60fd4c0d5",
urls = ["https://github.com/emacski/bazel-tools/archive/250e4a98908fa0c6631ebccdeae930a60fd4c0d5.tar.gz"],
)

register_toolchains("@com_github_emacski_bazeltools//toolchain/cpp/clang:all")

# python client deps

http_archive(
name = "rules_python",
sha256 = "afe33d4a8091452cb785108f237c7f3dcef56345952aad124954a96d89c4aab6",
Expand All @@ -40,63 +42,72 @@ load("@rules_python//python:pip.bzl", "pip_repositories")

pip_repositories()

# tensorflow 2.2.0
# https://github.com/tensorflow/tensorflow
# go client deps

http_archive(
name = "org_tensorflow",
sha256 = "b3d7829fac84e3a26264d84057367730b6b85b495a0fce15929568f4b55dc144",
strip_prefix = "tensorflow-2b96f3662bd776e277f86997659e61046b56c315",
name = "io_bazel_rules_go",
sha256 = "7904dbecbaffd068651916dce77ff3437679f9d20e1a7956bff43826e7645fcc",
urls = [
"https://github.com/tensorflow/tensorflow/archive/2b96f3662bd776e277f86997659e61046b56c315.tar.gz",
"https://mirror.bazel.build/github.com/bazelbuild/rules_go/releases/download/v0.25.1/rules_go-v0.25.1.tar.gz",
"https://github.com/bazelbuild/rules_go/releases/download/v0.25.1/rules_go-v0.25.1.tar.gz",
],
)

# see tensorflow/serving/WORKSPACE and tensorflow/tensorflow/WORKSPACE
http_archive(
name = "io_bazel_rules_closure",
sha256 = "5b00383d08dd71f28503736db0500b6fb4dda47489ff5fc6bed42557c07c6ba9",
strip_prefix = "rules_closure-308b05b2419edb5c8ee0471b67a40403df940149",
name = "bazel_gazelle",
sha256 = "222e49f034ca7a1d1231422cdb67066b885819885c356673cb1f72f748a3c9d4",
urls = [
"https://github.com/bazelbuild/rules_closure/archive/308b05b2419edb5c8ee0471b67a40403df940149.tar.gz",
"https://mirror.bazel.build/github.com/bazelbuild/bazel-gazelle/releases/download/v0.22.3/bazel-gazelle-v0.22.3.tar.gz",
"https://github.com/bazelbuild/bazel-gazelle/releases/download/v0.22.3/bazel-gazelle-v0.22.3.tar.gz",
],
)

# see tensorflow/serving/WORKSPACE and tensorflow/tensorflow/WORKSPACE
http_archive(
name = "bazel_skylib",
sha256 = "1dde365491125a3db70731e25658dfdd3bc5dbdfd11b840b3e987ecf043c7ca0",
urls = [
"https://storage.googleapis.com/mirror.tensorflow.org/github.com/bazelbuild/bazel-skylib/releases/download/0.9.0/bazel_skylib-0.9.0.tar.gz",
"https://github.com/bazelbuild/bazel-skylib/releases/download/0.9.0/bazel_skylib-0.9.0.tar.gz",
],
load("@io_bazel_rules_go//go:deps.bzl", "go_register_toolchains", "go_rules_dependencies")

go_rules_dependencies()

go_register_toolchains(version = "1.16")

load("@bazel_gazelle//:deps.bzl", "gazelle_dependencies", "go_repository")

gazelle_dependencies()

go_repository(
name = "org_golang_google_grpc",
commit = "f74f0337644653eba7923908a4d7f79a4f3a267b", # 1.36.0
importpath = "google.golang.org/grpc",
)

# see tensorflow/serving/WORKSPACE
http_archive(
name = "rules_pkg",
sha256 = "f8bf72e76a15d045f786ef0eba92e073a50bbdbd807d237a43a759d36b1b1e2c",
strip_prefix = "rules_pkg-0.2.5/pkg",
urls = ["https://github.com/bazelbuild/rules_pkg/archive/0.2.5.tar.gz"],
go_repository(
name = "org_golang_x_net",
importpath = "golang.org/x/net",
sum = "h1:oWX7TPOiFAMXLq8o0ikBYfCJVlRHBcsciT5bXOrH628=",
version = "v0.0.0-20190311183353-d8887717615a",
)

# https://github.com/tensorflow/serving
http_archive(
name = "tf_serving",
sha256 = "946c1a58d677686e6b986634b51f4bc19486230c7fc2ab669c8492b0662ad4cc",
strip_prefix = "serving-d22fc192c7ad7b48d9a81346224aff637b8988f1",
urls = [
"https://github.com/tensorflow/serving/archive/d22fc192c7ad7b48d9a81346224aff637b8988f1.tar.gz",
],
go_repository(
name = "org_golang_x_text",
importpath = "golang.org/x/text",
sum = "h1:g61tztE5qeGQ89tm6NTjjM9VPIm088od1l6aSorWRWg=",
version = "v0.3.0",
)

load("@tf_serving//tensorflow_serving:workspace.bzl", "tf_serving_workspace")
# protobuf / grpc deps

tf_serving_workspace()
http_archive(
name = "com_github_grpc_grpc",
patches = [
"@com_github_emacski_tensorflowservingarmclient//third_party/grpc:cython_library.patch",
],
sha256 = "bb6de0544adddd54662ba1c314eff974e84c955c39204a4a2b733ccd990354b7",
strip_prefix = "grpc-1.36.3",
urls = ["https://github.com/grpc/grpc/archive/v1.36.3.tar.gz"],
)

load("@com_github_grpc_grpc//bazel:grpc_deps.bzl", "grpc_deps")

grpc_deps()

load("@upb//bazel:repository_defs.bzl", "bazel_version_repository")
load("@com_github_grpc_grpc//bazel:grpc_extra_deps.bzl", "grpc_extra_deps")

bazel_version_repository(name = "bazel_version")
grpc_extra_deps()
32 changes: 32 additions & 0 deletions cc/BUILD
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# Copyright 2021 Erik Maciejewski
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

load(
"@com_github_emacski_bazeltools//protobuf:cc.bzl",
"cc_grpc_library",
"cc_proto_library",
)

package(default_visibility = ["//visibility:public"])

cc_grpc_library(
name = "tensorflow_serving",
srcs = ["//proto/tensorflow_serving/apis:protos_grpc_all"],
deps = [":tensorflow_serving_protobuf"],
)

cc_proto_library(
name = "tensorflow_serving_protobuf",
deps = ["//proto:protos_all"],
)
59 changes: 59 additions & 0 deletions go/BUILD
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
# Copyright 2021 Erik Maciejewski
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

load(
"@com_github_emacski_bazeltools//protobuf:go.bzl",
"go_grpc_library",
"go_proto_library",
)

package(default_visibility = ["//visibility:public"])

go_grpc_library(
name = "tensorflow_serving",
srcs = ["//proto/tensorflow_serving/apis:protos_grpc_all"],
importpath = "github.com/tensorflow-serving-arm-client/go/tensorflow_serving",
deps = [":tensorflow_serving_protobuf"],
)

go_proto_library(
name = "tensorflow_serving_protobuf",
importpath = "github.com/tensorflow-serving-arm-client/go/tensorflow_serving",
proto = ["//proto/tensorflow_serving:protos_all"],
deps = [
":tensorflow_core_proto",
":tensorflow_example_proto",
":tensorflow_framework_proto",
],
)

go_proto_library(
name = "tensorflow_core_proto",
importpath = "github.com/tensorflow-serving-arm-client/go/tensorflow/core",
proto = ["//proto/tensorflow/core:protos_all"],
deps = [":tensorflow_framework_proto"],
)

go_proto_library(
name = "tensorflow_framework_proto",
importpath = "github.com/tensorflow-serving-arm-client/go/tensorflow/core/framework",
proto = ["//proto/tensorflow/core/framework:protos_all"],
)

go_proto_library(
name = "tensorflow_example_proto",
importpath = "github.com/tensorflow-serving-arm-client/go/tensorflow/core/example",
proto = ["//proto/tensorflow/core/example:protos_all"],
deps = [":tensorflow_framework_proto"],
)
16 changes: 8 additions & 8 deletions python/BUILD → py/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -13,22 +13,22 @@
# limitations under the License.

load(
"@com_github_emacski_bazeltools//protobuf:python_rules.bzl",
"@com_github_emacski_bazeltools//protobuf:py.bzl",
"py_grpc_library",
"py_proto_library",
)

package(default_visibility = ["//visibility:public"])

py_proto_library(
name = "protobuf",
py_grpc_library(
name = "tensorflow_serving",
srcs = ["//proto/tensorflow_serving/apis:protos_grpc_all"],
srcs_version = "PY3",
deps = ["//proto:protos_all"],
deps = [":tensorflow_serving_protobuf"],
)

py_grpc_library(
name = "grpc",
srcs = ["//proto/tensorflow_serving/apis:protos_grpc_all"],
py_proto_library(
name = "tensorflow_serving_protobuf",
srcs_version = "PY3",
deps = [":protobuf"],
deps = ["//proto:protos_all"],
)
Loading

0 comments on commit a021aa0

Please sign in to comment.