From 9be1446d9188b28a73441fa486b2297f09e0e40e Mon Sep 17 00:00:00 2001 From: wangguibao Date: Fri, 22 Mar 2019 14:17:04 +0800 Subject: [PATCH] Add cmake option: CLIENT_ONLY - Compile client libraries and demos only Change-Id: I3029679e261524053c00ea985cfcafb3dfb49bf6 --- CMakeLists.txt | 32 ++++++++++++++++------ doc/INSTALL.md | 5 ++-- sdk-cpp/demo/dense_format.cpp | 2 +- sdk-cpp/demo/echo.cpp | 2 +- sdk-cpp/demo/int64tensor_format.cpp | 2 +- sdk-cpp/demo/sparse_format.cpp | 2 +- sdk-cpp/demo/text_classification.cpp | 2 +- sdk-cpp/demo/text_classification_press.cpp | 24 ++++++++++------ sdk-cpp/demo/ximage.cpp | 2 +- 9 files changed, 48 insertions(+), 25 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index adc8bc65..1df55911 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -43,8 +43,10 @@ set(THIRD_PARTY_PATH "${CMAKE_BINARY_DIR}/third_party" CACHE STRING set(THIRD_PARTY_BUILD_TYPE Release) -option(WITH_AVX "Compile PaddlePaddle with AVX intrinsics" ${AVX_FOUND}) -option(WITH_MKL "Compile PaddlePaddle with MKL support." ${AVX_FOUND}) +option(WITH_AVX "Compile Paddle Serving with AVX intrinsics" ${AVX_FOUND}) +option(WITH_MKL "Compile Paddle Serving with MKL support." ${AVX_FOUND}) +option(CLIENT_ONLY "Compile client libraries and demos only" + FALSE) set(WITH_MKLML ${WITH_MKL}) if (NOT DEFINED WITH_MKLDNN) @@ -56,19 +58,22 @@ if (NOT DEFINED WITH_MKLDNN) endif() endif() -include(external/mklml) +include(external/leveldb) include(external/zlib) +include(external/boost) +include(external/protobuf) +include(external/brpc) include(external/gflags) include(external/glog) -include(external/leveldb) -include(external/protobuf) include(external/snappy) -include(external/brpc) -include(external/boost) -include(flags) include(generic) +include(flags) + +if (NOT CLIENT_ONLY) +include(external/mklml) include(paddlepaddle) include(external/opencv) +endif() include_directories(${PADDLE_SERVING_SOURCE_DIR}) include_directories(${PADDLE_SERVING_BINARY_DIR}) @@ -81,6 +86,7 @@ set(EXTERNAL_LIBS brpc ) + if(WITH_MKLML) list(APPEND EXTERNAL_LIBS ${MKLML_IOMP_LIB}) endif() @@ -90,9 +96,17 @@ if(WITH_MKLDNN) list(APPEND EXTERNAL_LIBS ${MKLDNN_LIB}) endif() +if (NOT CLIENT_ONLY) + list(APPEND EXTERNAL_LIBS paddlepaddle) + list(APPEND EXTERNAL_LIBS opencv) +endif() + add_subdirectory(configure) add_subdirectory(pdcodegen) +add_subdirectory(sdk-cpp) + +if (NOT CLIENT_ONLY) add_subdirectory(predictor) add_subdirectory(inferencer-fluid-cpu) add_subdirectory(serving) -add_subdirectory(sdk-cpp) +endif() diff --git a/doc/INSTALL.md b/doc/INSTALL.md index 1285c905..64e482d6 100644 --- a/doc/INSTALL.md +++ b/doc/INSTALL.md @@ -60,7 +60,8 @@ $ make install 因Paddle Serving依托于PaddlePaddle项目进行构建,以下编译选项其实是传递给PaddlePaddle的编译选项: -| 编译选项 | 说明| -|----------|-----| +| 编译选项 | 说明 | +|----------|------| | WITH_AVX | Compile PaddlePaddle with AVX intrinsics | | WITH_MKL | Compile PaddlePaddle with MKLML library | +| CLINET_ONLY | Compile client libraries and demos only | diff --git a/sdk-cpp/demo/dense_format.cpp b/sdk-cpp/demo/dense_format.cpp index 43d73630..beb13877 100644 --- a/sdk-cpp/demo/dense_format.cpp +++ b/sdk-cpp/demo/dense_format.cpp @@ -17,7 +17,7 @@ #include #include -#include "predictor/builtin_format.pb.h" +#include "sdk-cpp/builtin_format.pb.h" #include "sdk-cpp/dense_service.pb.h" #include "sdk-cpp/include/common.h" #include "sdk-cpp/include/predictor_sdk.h" diff --git a/sdk-cpp/demo/echo.cpp b/sdk-cpp/demo/echo.cpp index b296cd28..ca68d2cb 100644 --- a/sdk-cpp/demo/echo.cpp +++ b/sdk-cpp/demo/echo.cpp @@ -17,7 +17,7 @@ #include #include -#include "predictor/builtin_format.pb.h" +#include "sdk-cpp/builtin_format.pb.h" #include "sdk-cpp/echo_service.pb.h" #include "sdk-cpp/include/common.h" #include "sdk-cpp/include/predictor_sdk.h" diff --git a/sdk-cpp/demo/int64tensor_format.cpp b/sdk-cpp/demo/int64tensor_format.cpp index 15db68a2..97160d82 100644 --- a/sdk-cpp/demo/int64tensor_format.cpp +++ b/sdk-cpp/demo/int64tensor_format.cpp @@ -17,7 +17,7 @@ #include #include -#include "predictor/builtin_format.pb.h" +#include "sdk-cpp/builtin_format.pb.h" #include "sdk-cpp/include/common.h" #include "sdk-cpp/include/predictor_sdk.h" #include "sdk-cpp/int64tensor_service.pb.h" diff --git a/sdk-cpp/demo/sparse_format.cpp b/sdk-cpp/demo/sparse_format.cpp index 78c237d7..c428881d 100644 --- a/sdk-cpp/demo/sparse_format.cpp +++ b/sdk-cpp/demo/sparse_format.cpp @@ -17,7 +17,7 @@ #include #include -#include "predictor/builtin_format.pb.h" +#include "sdk-cpp/builtin_format.pb.h" #include "sdk-cpp/include/common.h" #include "sdk-cpp/include/predictor_sdk.h" #include "sdk-cpp/sparse_service.pb.h" diff --git a/sdk-cpp/demo/text_classification.cpp b/sdk-cpp/demo/text_classification.cpp index 493a24b9..6e9555d0 100644 --- a/sdk-cpp/demo/text_classification.cpp +++ b/sdk-cpp/demo/text_classification.cpp @@ -17,7 +17,7 @@ #include #include -#include "predictor/builtin_format.pb.h" +#include "sdk-cpp/builtin_format.pb.h" #include "sdk-cpp/include/common.h" #include "sdk-cpp/include/predictor_sdk.h" #include "sdk-cpp/text_classification.pb.h" diff --git a/sdk-cpp/demo/text_classification_press.cpp b/sdk-cpp/demo/text_classification_press.cpp index a51afa3f..04a9d2f6 100644 --- a/sdk-cpp/demo/text_classification_press.cpp +++ b/sdk-cpp/demo/text_classification_press.cpp @@ -19,7 +19,7 @@ #include #include #include // NOLINT -#include "predictor/builtin_format.pb.h" +#include "sdk-cpp/builtin_format.pb.h" #include "sdk-cpp/include/common.h" #include "sdk-cpp/include/predictor_sdk.h" #include "sdk-cpp/text_classification.pb.h" @@ -328,18 +328,26 @@ int main(int argc, char **argv) { LOG(INFO) << "Total requests: " << round_times.size(); LOG(INFO) << "Max concurrency: " << FLAGS_concurrency; LOG(INFO) << "Elapse ms (wall-time): " << elapse_ms; - double qps = (static_cast(count) / elapse_ms) * 1000; + + double qps = 0.0; + if (elapse_ms != 0) { + qps = (static_cast(count) / elapse_ms) * 1000; + } LOG(INFO) << "QPS: " << qps / FLAGS_batch_size << "/s"; LOG(INFO) << "Accuracy " << static_cast(correct) / count; LOG(INFO) << "Latency statistics: "; - LOG(INFO) << "Average ms: " << total_ms / round_times.size(); - LOG(INFO) << "50 percent ms: " << round_times[percent_pos_50]; - LOG(INFO) << "80 percent ms: " << round_times[percent_pos_80]; - LOG(INFO) << "90 percent ms: " << round_times[percent_pos_90]; - LOG(INFO) << "99 percent ms: " << round_times[percent_pos_99]; - LOG(INFO) << "99.9 percent ms: " << round_times[percent_pos_999]; + if (round_times.size() != 0) { + LOG(INFO) << "Average ms: " << total_ms / round_times.size(); + LOG(INFO) << "50 percent ms: " << round_times[percent_pos_50]; + LOG(INFO) << "80 percent ms: " << round_times[percent_pos_80]; + LOG(INFO) << "90 percent ms: " << round_times[percent_pos_90]; + LOG(INFO) << "99 percent ms: " << round_times[percent_pos_99]; + LOG(INFO) << "99.9 percent ms: " << round_times[percent_pos_999]; + } else { + LOG(INFO) << "N/A"; + } return 0; } diff --git a/sdk-cpp/demo/ximage.cpp b/sdk-cpp/demo/ximage.cpp index 226f6420..426a138e 100644 --- a/sdk-cpp/demo/ximage.cpp +++ b/sdk-cpp/demo/ximage.cpp @@ -17,7 +17,7 @@ #include #include -#include "predictor/builtin_format.pb.h" +#include "sdk-cpp/builtin_format.pb.h" #include "sdk-cpp/image_class.pb.h" #include "sdk-cpp/include/common.h" #include "sdk-cpp/include/predictor_sdk.h" -- GitLab