CMakeLists.txt 4.3 KB
Newer Older
1
if (CLIENT)
Z
zhangjun 已提交
2 3 4 5 6
  file(INSTALL pipeline DESTINATION paddle_serving_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")
G
guru4elephant 已提交
7 8
endif()

9
if (SERVER)
Z
zhangjun 已提交
10
  SET(SERVER_PACKAGE_NAME "paddle-serving-server")
Z
update  
zhangjun 已提交
11 12 13 14 15
  if (WITH_GPU) 
    set(SERVER_PACKAGE_NAME "paddle-serving-server-gpu")
  elseif(WITH_XPU)
    set(SERVER_PACKAGE_NAME "paddle-serving-server-xpu")
  endif()
Z
zhangjun 已提交
16 17 18 19
  file(INSTALL pipeline DESTINATION paddle_serving_server)
  file(GLOB_RECURSE SERVING_SERVER_PY_FILES paddle_serving_server/*.py)
  set(PY_FILES ${SERVING_SERVER_PY_FILES})
  set(SETUP_LOG_FILE "setup.py.server.log")
G
guru4elephant 已提交
20
endif()
G
guru4elephant 已提交
21

B
barriery 已提交
22 23
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/util.py
    ${CMAKE_CURRENT_BINARY_DIR}/util.py)
24
if (CLIENT)
Z
zhangjun 已提交
25
  configure_file(${CMAKE_CURRENT_SOURCE_DIR}/setup.py.client.in
G
guru4elephant 已提交
26
    ${CMAKE_CURRENT_BINARY_DIR}/setup.py)
Z
zhangjun 已提交
27
  configure_file(${CMAKE_CURRENT_SOURCE_DIR}/../tools/python_tag.py
M
MRXLT 已提交
28
    ${CMAKE_CURRENT_BINARY_DIR}/python_tag.py)
G
guru4elephant 已提交
29 30
endif()

31
if (APP)
Z
zhangjun 已提交
32
  configure_file(${CMAKE_CURRENT_SOURCE_DIR}/setup.py.app.in
33 34 35 36
    ${CMAKE_CURRENT_BINARY_DIR}/setup.py)
endif()

if (SERVER)
Z
zhangjun 已提交
37 38
  configure_file(${CMAKE_CURRENT_SOURCE_DIR}/setup.py.server.in
    ${CMAKE_CURRENT_BINARY_DIR}/setup.py)
G
guru4elephant 已提交
39
endif()
G
guru4elephant 已提交
40

M
MRXLT 已提交
41 42 43
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/gen_version.py
    ${CMAKE_CURRENT_BINARY_DIR}/gen_version.py)

M
bug fix  
MRXLT 已提交
44
set (SERVING_CLIENT_CORE ${PADDLE_SERVING_BINARY_DIR}/core/general-client/*.so)
G
guru4elephant 已提交
45 46
message("python env: " ${py_env})

47
if (APP)
Z
zhangjun 已提交
48 49 50 51 52 53 54
  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} gen_version.py "app"
    COMMAND env ${py_env} ${PYTHON_EXECUTABLE} setup.py bdist_wheel
    DEPENDS ${SERVING_APP_CORE} general_model_config_py_proto ${PY_FILES})
  add_custom_target(paddle_python ALL DEPENDS ${PADDLE_SERVING_BINARY_DIR}/.timestamp)
55 56 57
endif()

if (CLIENT)
Z
zhangjun 已提交
58 59 60 61
  add_custom_command(
    OUTPUT ${PADDLE_SERVING_BINARY_DIR}/.timestamp
    COMMAND cp -r ${CMAKE_CURRENT_SOURCE_DIR}/paddle_serving_client/ ${PADDLE_SERVING_BINARY_DIR}/python/
    COMMAND ${CMAKE_COMMAND} -E copy ${SERVING_CLIENT_CORE} ${PADDLE_SERVING_BINARY_DIR}/python/paddle_serving_client/serving_client.so
M
MRXLT 已提交
62
    COMMAND env ${py_env} ${PYTHON_EXECUTABLE} python_tag.py
M
MRXLT 已提交
63
    COMMAND env ${py_env} ${PYTHON_EXECUTABLE} gen_version.py "client"
Z
zhangjun 已提交
64 65 66
    COMMAND env ${py_env} ${PYTHON_EXECUTABLE} setup.py bdist_wheel
    DEPENDS ${SERVING_CLIENT_CORE} sdk_configure_py_proto ${PY_FILES})
  add_custom_target(paddle_python ALL DEPENDS serving_client ${PADDLE_SERVING_BINARY_DIR}/.timestamp)
G
guru4elephant 已提交
67 68
endif()

69
if (SERVER)
Z
zhangjun 已提交
70 71 72 73 74
  # todo, generate suffix for cpu、gpu、arm
  if(WITH_TRT)
    if(CUDA_VERSION EQUAL 10.1)
      set(VERSION_SUFFIX 101)
    elseif(CUDA_VERSION EQUAL 10.2)
75 76 77 78 79 80 81
      if(CUDNN_MAJOR_VERSION EQUAL 7)
        set(VERSION_SUFFIX 1027)
      elseif(CUDNN_MAJOR_VERSION EQUAL 8)
        set(VERSION_SUFFIX 1028)
      endif()
    elseif(CUDA_VERSION EQUAL 11.2)
      set(VERSION_SUFFIX 112)
Z
zhangjun 已提交
82 83 84 85
    endif()
  endif()

  if(WITH_LITE)
Z
update  
zhangjun 已提交
86
    set(VERSION_SUFFIX 2)
Z
zhangjun 已提交
87 88 89 90 91 92 93 94 95 96
  endif()
  add_custom_command(
    OUTPUT ${PADDLE_SERVING_BINARY_DIR}/.timestamp
    COMMAND cp -r
    ${CMAKE_CURRENT_SOURCE_DIR}/paddle_serving_server/ ${PADDLE_SERVING_BINARY_DIR}/python/
    COMMAND env ${py_env} ${PYTHON_EXECUTABLE} gen_version.py
    "server" ${VERSION_SUFFIX}
    COMMAND env ${py_env} ${PYTHON_EXECUTABLE} setup.py bdist_wheel
    DEPENDS ${SERVING_SERVER_CORE} server_config_py_proto ${PY_FILES})
  add_custom_target(paddle_python ALL DEPENDS ${PADDLE_SERVING_BINARY_DIR}/.timestamp)
G
guru4elephant 已提交
97
endif()
G
guru4elephant 已提交
98 99

set(SERVING_CLIENT_PYTHON_PACKAGE_DIR ${CMAKE_CURRENT_BINARY_DIR}/dist/)
G
guru4elephant 已提交
100
set(SERVING_SERVER_PYTHON_PACKAGE_DIR ${CMAKE_CURRENT_BINARY_DIR}/dist/)
G
guru4elephant 已提交
101

102
if (CLIENT)
Z
zhangjun 已提交
103
  install(DIRECTORY ${SERVING_CLIENT_PYTHON_PACKAGE_DIR}
G
guru4elephant 已提交
104
    DESTINATION opt/serving_client/share/wheels
Z
zhangjun 已提交
105
  )
G
guru4elephant 已提交
106 107
endif()

108
if (SERVER)
Z
zhangjun 已提交
109 110 111
  install(DIRECTORY ${SERVING_SERVER_PYTHON_PACKAGE_DIR}
      DESTINATION opt/serving_server/share/wheels
  )
G
guru4elephant 已提交
112
endif()
G
guru4elephant 已提交
113

114
if (CLIENT OR SERVER)
Z
zhangjun 已提交
115 116 117 118 119
  find_program(PATCHELF_EXECUTABLE patchelf)
  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()
120
endif()