diff --git a/CMakeLists.txt b/CMakeLists.txt index f4e8c64c4ff73d0a417c35159901c2e67d0ca4ef..af065158699199af61aca02f563dda1b1cddf2b1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -49,7 +49,9 @@ set(THIRD_PARTY_BUILD_TYPE Release) option(WITH_AVX "Compile Paddle Serving with AVX intrinsics" OFF) option(WITH_MKL "Compile Paddle Serving with MKL support." OFF) option(WITH_GPU "Compile Paddle Serving with NVIDIA GPU" OFF) -option(CLIENT_ONLY "Compile client libraries and demos only" OFF) +option(CLIENT "Compile Paddle Serving Client" OFF) +option(SERVER "Compile Paddle Serving Server" OFF) +option(APP "Compile Paddle Serving App package" OFF) option(WITH_ELASTIC_CTR "Compile ELASITC-CTR solution" OFF) option(PACK "Compile for whl" OFF) @@ -63,12 +65,12 @@ if (NOT DEFINED WITH_MKLDNN) endif() endif() -if (NOT CLIENT_ONLY) +if (SERVER) include(external/jsoncpp) #include(external/rocksdb) endif() -#include(external/gtest) +if (SERVER OR CLIENT) include(external/snappy) include(external/leveldb) include(external/zlib) @@ -81,8 +83,9 @@ include(external/pybind11) include(external/python) include(generic) include(flags) +endif() -if (NOT CLIENT_ONLY) +if (SERVER) include(external/cudnn) include(paddlepaddle) endif() @@ -91,7 +94,7 @@ message("paddle serving source dir: " ${PADDLE_SERVING_SOURCE_DIR}) include_directories(${PADDLE_SERVING_SOURCE_DIR}) include_directories(${PADDLE_SERVING_BINARY_DIR}) -if(NOT CLIENT_ONLY) +if(SERVER) set(EXTERNAL_LIBS jsoncpp gflags @@ -109,28 +112,27 @@ set(EXTERNAL_LIBS brpc ) -if(NOT CLIENT_ONLY) +if(SERVER) if(WITH_MKLML) list(APPEND EXTERNAL_LIBS ${MKLML_IOMP_LIB}) endif() endif() -if(NOT CLIENT_ONLY) +if(SERVER) if(WITH_MKLDNN) list(APPEND EXTERNAL_LIBS ${MKLDNN_LIB}) endif() endif() -if (NOT CLIENT_ONLY) +if (SERVER) list(APPEND EXTERNAL_LIBS paddlepaddle) endif() add_subdirectory(core) -if(NOT CLIENT_ONLY) +if(SERVER) add_subdirectory(paddle_inference) endif() add_subdirectory(python) -#add_subdirectory(examples) diff --git a/core/CMakeLists.txt b/core/CMakeLists.txt index 7226a69a87163cf625f49f54fe2a7df996a98efd..ce2e5e3814ae1e585976c5d9c8848b506293ee67 100644 --- a/core/CMakeLists.txt +++ b/core/CMakeLists.txt @@ -12,19 +12,26 @@ # See the License for the specific language governing permissions and # limitations under the License -if(NOT CLIENT_ONLY) +if(SERVER) add_subdirectory(cube) #add_subdirectory(kvdb) endif() + +if (CLIENT OR SERVER) add_subdirectory(configure) add_subdirectory(pdcodegen) add_subdirectory(sdk-cpp) -if(CLIENT_ONLY) +endif() + +if(CLIENT) add_subdirectory(general-client) endif() -if (NOT CLIENT_ONLY) +if (SERVER) add_subdirectory(predictor) add_subdirectory(general-server) endif() + +if (CLIENT OR SERVER) add_subdirectory(util) +endif() diff --git a/core/configure/CMakeLists.txt b/core/configure/CMakeLists.txt index 685eff01837cbc86dab33524b14e796f6f7573f2..b6384fc99ea3df6d71a61865e3aabf5b39b510dd 100644 --- a/core/configure/CMakeLists.txt +++ b/core/configure/CMakeLists.txt @@ -33,7 +33,7 @@ py_proto_compile(general_model_config_py_proto SRCS proto/general_model_config.p add_custom_target(general_model_config_py_proto_init ALL COMMAND ${CMAKE_COMMAND} -E touch __init__.py) add_dependencies(general_model_config_py_proto general_model_config_py_proto_init) -if (CLIENT_ONLY) +if (CLIENT) py_proto_compile(sdk_configure_py_proto SRCS proto/sdk_configure.proto) add_custom_target(sdk_configure_py_proto_init ALL COMMAND ${CMAKE_COMMAND} -E touch __init__.py) add_dependencies(sdk_configure_py_proto sdk_configure_py_proto_init) @@ -51,7 +51,7 @@ add_custom_command(TARGET general_model_config_py_proto POST_BUILD endif() -if (NOT CLIENT_ONLY) +if (SERVER) py_proto_compile(server_config_py_proto SRCS proto/server_configure.proto) add_custom_target(server_config_py_proto_init ALL COMMAND ${CMAKE_COMMAND} -E touch __init__.py) add_dependencies(server_config_py_proto server_config_py_proto_init) diff --git a/core/general-client/CMakeLists.txt b/core/general-client/CMakeLists.txt index f3bb666a3a0eb114463e941fdaa1ba8134337bb1..88abcbcb776ae999cbf9123d1dad0864a987ecf4 100644 --- a/core/general-client/CMakeLists.txt +++ b/core/general-client/CMakeLists.txt @@ -1,4 +1,4 @@ -if(CLIENT_ONLY) +if(CLIENT) add_subdirectory(pybind11) pybind11_add_module(serving_client src/general_model.cpp src/pybind_general_model.cpp) target_link_libraries(serving_client PRIVATE -Wl,--whole-archive utils sdk-cpp pybind python -Wl,--no-whole-archive -lpthread -lcrypto -lm -lrt -lssl -ldl -lz) diff --git a/python/CMakeLists.txt b/python/CMakeLists.txt index 855b006949e8b621260e7ed86c4a8c86e2332104..c1590fb1b36de669f89711f95c4d49aedadb0c91 100644 --- a/python/CMakeLists.txt +++ b/python/CMakeLists.txt @@ -1,11 +1,11 @@ -if (CLIENT_ONLY) +if (CLIENT) file(GLOB_RECURSE SERVING_CLIENT_PY_FILES paddle_serving_client/*.py) set(PY_FILES ${SERVING_CLIENT_PY_FILES}) SET(PACKAGE_NAME "serving_client") set(SETUP_LOG_FILE "setup.py.client.log") endif() -if (NOT CLIENT_ONLY) +if (SERVER) if (NOT WITH_GPU) file(GLOB_RECURSE SERVING_SERVER_PY_FILES paddle_serving_server/*.py) else() @@ -16,12 +16,17 @@ if (NOT CLIENT_ONLY) set(SETUP_LOG_FILE "setup.py.server.log") endif() -if (CLIENT_ONLY) +if (CLIENT) configure_file(${CMAKE_CURRENT_SOURCE_DIR}/setup.py.client.in ${CMAKE_CURRENT_BINARY_DIR}/setup.py) endif() -if (NOT CLIENT_ONLY) +if (APP) +configure_file(${CMAKE_CURRENT_SOURCE_DIR}/setup.py.app.in + ${CMAKE_CURRENT_BINARY_DIR}/setup.py) +endif() + +if (SERVER) if (NOT WITH_GPU) configure_file(${CMAKE_CURRENT_SOURCE_DIR}/setup.py.server.in ${CMAKE_CURRENT_BINARY_DIR}/setup.py) @@ -34,7 +39,15 @@ endif() set (SERVING_CLIENT_CORE ${PADDLE_SERVING_BINARY_DIR}/core/general-client/*.so) message("python env: " ${py_env}) -if (CLIENT_ONLY) +if (APP) +add_custom_command( + OUTPUT ${PADDLE_SERVING_BINARY_DIR}/.timestamp + COMMAND cp -r ${CMAKE_CURRENT_SOURCE_DIR}/paddle_serving_app/ ${PADDLE_SERVING_BINARY_DIR}/python/ + COMMAND env ${py_env} ${PYTHON_EXECUTABLE} setup.py bdist_wheel) +add_custom_target(paddle_python ALL DEPENDS ${PADDLE_SERVING_BINARY_DIR}/.timestamp) +endif() + +if (CLIENT) add_custom_command( OUTPUT ${PADDLE_SERVING_BINARY_DIR}/.timestamp COMMAND cp -r ${CMAKE_CURRENT_SOURCE_DIR}/paddle_serving_client/ ${PADDLE_SERVING_BINARY_DIR}/python/ @@ -44,7 +57,7 @@ add_custom_command( add_custom_target(paddle_python ALL DEPENDS serving_client ${PADDLE_SERVING_BINARY_DIR}/.timestamp) endif() -if (NOT CLIENT_ONLY) +if (SERVER) if(NOT WITH_GPU) add_custom_command( OUTPUT ${PADDLE_SERVING_BINARY_DIR}/.timestamp @@ -66,20 +79,22 @@ endif() set(SERVING_CLIENT_PYTHON_PACKAGE_DIR ${CMAKE_CURRENT_BINARY_DIR}/dist/) set(SERVING_SERVER_PYTHON_PACKAGE_DIR ${CMAKE_CURRENT_BINARY_DIR}/dist/) -if (CLIENT_ONLY) +if (CLIENT) install(DIRECTORY ${SERVING_CLIENT_PYTHON_PACKAGE_DIR} DESTINATION opt/serving_client/share/wheels ) endif() -if (NOT CLIENT_ONLY) +if (SERVER) install(DIRECTORY ${SERVING_SERVER_PYTHON_PACKAGE_DIR} DESTINATION opt/serving_server/share/wheels ) endif() +if (CLIENT OR SERVER) find_program(PATCHELF_EXECUTABLE patchelf) -if(NOT PATCHELF_EXECUTABLE) +if (NOT PATCHELF_EXECUTABLE) message(FATAL_ERROR "patchelf not found, please install it.\n" "For Ubuntu, the command is: apt-get install -y patchelf.") endif() +endif() diff --git a/tools/serving_build.sh b/tools/serving_build.sh index 8bb305c750b7b6a60eaeb44bcbfa87746f7f25dc..7b6dc92d98645cc8ea62542e6c538a42567ecf83 100644 --- a/tools/serving_build.sh +++ b/tools/serving_build.sh @@ -58,7 +58,7 @@ function build_client() { cmake -DPYTHON_INCLUDE_DIR=$PYTHONROOT/include/python2.7/ \ -DPYTHON_LIBRARIES=$PYTHONROOT/lib64/libpython2.7.so \ -DPYTHON_EXECUTABLE=$PYTHONROOT/bin/python \ - -DCLIENT_ONLY=ON .. + -DCLIENT=ON .. rerun "make -j2 >/dev/null" 3 # due to some network reasons, compilation may fail pip install -U python/dist/paddle_serving_client* >/dev/null ;; @@ -82,7 +82,7 @@ function build_server() { cmake -DPYTHON_INCLUDE_DIR=$PYTHONROOT/include/python2.7/ \ -DPYTHON_LIBRARIES=$PYTHONROOT/lib64/libpython2.7.so \ -DPYTHON_EXECUTABLE=$PYTHONROOT/bin/python \ - -DCLIENT_ONLY=OFF .. + -DSERVER=OFF .. rerun "make -j2 >/dev/null" 3 # due to some network reasons, compilation may fail check_cmd "make install -j2 >/dev/null" pip install -U python/dist/paddle_serving_server* >/dev/null @@ -91,7 +91,7 @@ function build_server() { cmake -DPYTHON_INCLUDE_DIR=$PYTHONROOT/include/python2.7/ \ -DPYTHON_LIBRARIES=$PYTHONROOT/lib64/libpython2.7.so \ -DPYTHON_EXECUTABLE=$PYTHONROOT/bin/python \ - -DCLIENT_ONLY=OFF \ + -DSERVER=ON \ -DWITH_GPU=ON .. rerun "make -j2 >/dev/null" 3 # due to some network reasons, compilation may fail check_cmd "make install -j2 >/dev/null" @@ -111,6 +111,7 @@ function kill_server_process() { ps -ef | grep "serving" | grep -v serving_build | grep -v grep | awk '{print $2}' | xargs kill } + function python_test_fit_a_line() { # pwd: /Serving/python/examples cd fit_a_line # pwd: /Serving/python/examples/fit_a_line