Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

增加C++调用Adlik的接口和示例 #486

Closed
Jack-1008 opened this issue Jun 30, 2021 · 4 comments
Closed

增加C++调用Adlik的接口和示例 #486

Jack-1008 opened this issue Jun 30, 2021 · 4 comments
Assignees
Labels
documentation Improvements or additions to documentation

Comments

@Jack-1008
Copy link

我们需要使用C++通过远程grpc的方式集成Adlik,希望获取接口和示例支撑

@amadeus-zte amadeus-zte added the documentation Improvements or additions to documentation label Jun 30, 2021
@wangzhenyu32
Copy link
Contributor

wangzhenyu32 commented Jul 2, 2021

按照如下目录构建proto文件夹,其中tensorflow目录下的proto文件,在tensorflow源码中对应目录可以找到。注意tensorlfow版本,目前adlik使用tensorflow版本为2.4.0。 注意:protobuf版本为3.9.2

include/
|-- adlik_serving
| |-- apis
| | |-- get_model_meta.proto
| | |-- predict.proto
| | |-- predict_service.proto
| -- framework | -- domain
| |-- model_config.proto
| |-- model_spec.proto
| |-- version_policy.proto

|-- tensorflow
-- core -- framework
|-- resource_handle.proto
|-- tensor.proto
|-- tensor_shape.proto
`-- types.proto

@XueweiHan21
Copy link
Contributor

XueweiHan21 commented Jul 6, 2021

使用C++通过远程grpc的方式集成Adlik示例
1.构建proto文件夹(tensorflow版本为2.4.0,protobuf版本为3.9.2)
include/
|-- adlik_serving
| |-- apis
| | |-- get_model_meta.proto
| | |-- predict.proto
| | -- predict_service.proto | -- framework
| -- domain | |-- model_config.proto | |-- model_spec.proto | -- version_policy.proto
-- tensorflow -- core
-- framework |-- resource_handle.proto |-- tensor.proto |-- tensor_shape.proto -- types.proto
2.准备编译环境
apt-get install -y build-essential pkg-config autoconf automake libtool shtool libgflags2.2 libgflags-dev g++ make cmake git
3.安装protobuf 3.9.2
1)clone 代码

git clone https://github.com/google/protobuf.git`
cd protobuf 
git checkout v3.9.2

2)安装

sh ./autogen.sh  
./configure 
make && make install  

3)查看版本
protoc --version
4.安装grpc(grpc>=1.0<2)
1)检查cmake版本(cmake>=3.13)
cmake --version
2)Clone 代码
git clone --recurse-submodules -b v1.38.0 https://github.com/grpc/grpc
3)安装

$ cd grpc
$ mkdir -p cmake/build
$ pushd cmake/build
$ cmake -DgRPC_INSTALL=ON \
      -DgRPC_BUILD_TESTS=OFF \
      -DCMAKE_INSTALL_PREFIX=$MY_INSTALL_DIR \
      ../..
$ make -j
$ make install
$ popd
$ mkdir -p third_party/abseil-cpp/cmake/build
$ pushd third_party/abseil-cpp/cmake/build
$ cmake -DCMAKE_INSTALL_PREFIX=$MY_INSTALL_DIR \
      -DCMAKE_POSITION_INDEPENDENT_CODE=TRUE \
      ../..
$ make -j
$ make install
$ popd

5.编译生成Adlik C++ grpc client 源文件

protoc --proto_path=include --cpp_out=test include/adlik_serving/apis/*.proto include/tensorflow/core/framework/*.proto include/adlik_serving/framework/domain/*.proto
protoc --proto_path=include --grpc_out=test --plugin=protoc-gen-grpc=`which grpc_cpp_plugin` include/adlik_serving/apis/*.proto include/tensorflow/core/framework/*.proto include/adlik_serving/framework/domain/*.proto

6.将Adlik/adlik_serving/clients/cpp/cpp_client.cc 放在proto文件夹下,gcc 编译所有文件得到可执行文件cpp_client

XueweiHan21 added a commit that referenced this issue Jul 6, 2021
Closes #486.

Signed-off-by: HanXuewei <han.xuewei@zte.com.cn>
@XueweiHan21
Copy link
Contributor

include文件夹及已经编译生成的test文件夹位于Adilk cpp-client分支
@Jack-1008

@wangzhenyu32
Copy link
Contributor

Adlik 代码提交流程说明

  1. git clone 代码库
    

https://github.com/Adlik/Adlik.git

git checkout –b cmake-client

  1. 添加cmake文件
    

cp cmakelists.txt Adilik/adlik_serving/clients/cpp

  1. Git 添加
    

cd Adlik

git add .

git commit –m”support client cmake build”

  1. 推送到github库
    

git push origin cmake-client:cmake-client

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants