CMakeLists.txt 6.8 KB
Newer Older
1
if (CLIENT)
B
barrierye 已提交
2
    file(INSTALL pipeline DESTINATION paddle_serving_client)
M
MRXLT 已提交
3 4 5 6
    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
    if (NOT WITH_GPU AND NOT WITH_LITE)
11
        file(INSTALL pipeline DESTINATION paddle_serving_server)
M
MRXLT 已提交
12 13
        file(GLOB_RECURSE SERVING_SERVER_PY_FILES paddle_serving_server/*.py)
    else()
14
        file(INSTALL pipeline DESTINATION paddle_serving_server_gpu)
M
MRXLT 已提交
15 16 17 18 19
        file(GLOB_RECURSE SERVING_SERVER_PY_FILES paddle_serving_server_gpu/*.py)
    endif()
        set(PY_FILES ${SERVING_SERVER_PY_FILES})
        SET(PACKAGE_NAME "serving_server")
        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)
G
guru4elephant 已提交
25
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/setup.py.client.in
G
guru4elephant 已提交
26
    ${CMAKE_CURRENT_BINARY_DIR}/setup.py)
M
MRXLT 已提交
27 28
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/../tools/python_tag.py
    ${CMAKE_CURRENT_BINARY_DIR}/python_tag.py)
G
guru4elephant 已提交
29 30
endif()

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

if (SERVER)
Z
zhangjun 已提交
37
    if (NOT WITH_GPU AND NOT WITH_LITE)
M
MRXLT 已提交
38 39 40 41 42 43
        configure_file(${CMAKE_CURRENT_SOURCE_DIR}/setup.py.server.in
            ${CMAKE_CURRENT_BINARY_DIR}/setup.py)
    else()
        configure_file(${CMAKE_CURRENT_SOURCE_DIR}/setup.py.server_gpu.in
            ${CMAKE_CURRENT_BINARY_DIR}/setup.py)
    endif()
G
guru4elephant 已提交
44
endif()
G
guru4elephant 已提交
45

M
MRXLT 已提交
46 47 48
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/gen_version.py
    ${CMAKE_CURRENT_BINARY_DIR}/gen_version.py)

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

52 53 54 55
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/
M
MRXLT 已提交
56
        COMMAND env ${py_env} ${PYTHON_EXECUTABLE} gen_version.py "app"
M
MRXLT 已提交
57 58
        COMMAND env ${py_env} ${PYTHON_EXECUTABLE} setup.py bdist_wheel
        DEPENDS ${SERVING_APP_CORE} general_model_config_py_proto ${PY_FILES})
59 60 61 62
add_custom_target(paddle_python ALL DEPENDS ${PADDLE_SERVING_BINARY_DIR}/.timestamp)
endif()

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

74
if (SERVER)
Z
zhangjun 已提交
75
    if(NOT WITH_GPU AND NOT WITH_LITE)
M
MRXLT 已提交
76 77 78
        add_custom_command(
            OUTPUT ${PADDLE_SERVING_BINARY_DIR}/.timestamp
            COMMAND cp -r ${CMAKE_CURRENT_SOURCE_DIR}/paddle_serving_server/ ${PADDLE_SERVING_BINARY_DIR}/python/
M
MRXLT 已提交
79
            COMMAND env ${py_env} ${PYTHON_EXECUTABLE} gen_version.py "server"
M
MRXLT 已提交
80 81 82
            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)
M
MRXLT 已提交
83
    elseif(WITH_TRT)
W
wangjiawei04 已提交
84 85 86 87 88
        if(CUDA_VERSION EQUAL 10.1)
            set(SUFFIX 101)
        elseif(CUDA_VERSION EQUAL 10.2)
            set(SUFFIX 102)
        elseif(CUDA_VERSION EQUAL 11.0)
W
wangjiawei04 已提交
89
            set(SUFFIX 11)
W
wangjiawei04 已提交
90 91

        endif()
M
MRXLT 已提交
92 93 94 95 96
        add_custom_command(
            OUTPUT ${PADDLE_SERVING_BINARY_DIR}/.timestamp
            COMMAND cp -r
            ${CMAKE_CURRENT_SOURCE_DIR}/paddle_serving_server_gpu/ ${PADDLE_SERVING_BINARY_DIR}/python/
            COMMAND env ${py_env} ${PYTHON_EXECUTABLE} gen_version.py
W
wangjiawei04 已提交
97
            "server_gpu"  ${SUFFIX}
M
MRXLT 已提交
98 99 100
            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)
Z
zhangjun 已提交
101
    elseif(WITH_LITE)
Z
zhangjun 已提交
102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122
        if(WITH_XPU)
            add_custom_command(
                OUTPUT ${PADDLE_SERVING_BINARY_DIR}/.timestamp
                COMMAND cp -r
                ${CMAKE_CURRENT_SOURCE_DIR}/paddle_serving_server_gpu/ ${PADDLE_SERVING_BINARY_DIR}/python/
                COMMAND env ${py_env} ${PYTHON_EXECUTABLE} gen_version.py
                "server_gpu" arm-xpu 
                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)
        else()
            add_custom_command(
                OUTPUT ${PADDLE_SERVING_BINARY_DIR}/.timestamp
                COMMAND cp -r
                ${CMAKE_CURRENT_SOURCE_DIR}/paddle_serving_server_gpu/ ${PADDLE_SERVING_BINARY_DIR}/python/
                COMMAND env ${py_env} ${PYTHON_EXECUTABLE} gen_version.py
                "server_gpu" arm 
                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)
        endif()
M
MRXLT 已提交
123 124 125 126 127
    else()
        add_custom_command(
            OUTPUT ${PADDLE_SERVING_BINARY_DIR}/.timestamp
            COMMAND cp -r
            ${CMAKE_CURRENT_SOURCE_DIR}/paddle_serving_server_gpu/ ${PADDLE_SERVING_BINARY_DIR}/python/
M
MRXLT 已提交
128 129
            COMMAND env ${py_env} ${PYTHON_EXECUTABLE} gen_version.py
            "server_gpu" ${CUDA_VERSION_MAJOR}
M
MRXLT 已提交
130 131 132 133
            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)
    endif()
G
guru4elephant 已提交
134
endif()
G
guru4elephant 已提交
135 136

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

139
if (CLIENT)
G
guru4elephant 已提交
140 141 142
install(DIRECTORY ${SERVING_CLIENT_PYTHON_PACKAGE_DIR}
    DESTINATION opt/serving_client/share/wheels
)
G
guru4elephant 已提交
143 144
endif()

145
if (SERVER)
G
guru4elephant 已提交
146 147 148 149
install(DIRECTORY ${SERVING_SERVER_PYTHON_PACKAGE_DIR}
    DESTINATION opt/serving_server/share/wheels
)
endif()
G
guru4elephant 已提交
150

151
if (CLIENT OR SERVER)
G
guru4elephant 已提交
152
find_program(PATCHELF_EXECUTABLE patchelf)
153
if (NOT PATCHELF_EXECUTABLE)
G
guru4elephant 已提交
154 155 156
  message(FATAL_ERROR "patchelf not found, please install it.\n"
         "For Ubuntu, the command is: apt-get install -y patchelf.")
endif()
157
endif()