fix libpython3.so not found on gpu

Signed-off-by: zhoufeng <zhoufeng54@huawei.com>
This commit is contained in:
zhoufeng 2022-10-25 09:45:44 +08:00
parent b7d53f7da3
commit d0b9ba4f26
2 changed files with 24 additions and 4 deletions

View File

@ -90,6 +90,14 @@ install(
COMPONENT mindspore
)
if(ENABLE_D OR ENABLE_GPU)
install(
TARGETS api_lib
DESTINATION ${INSTALL_LIB_DIR}
COMPONENT mindspore
)
endif()
install(
TARGETS mindspore_core mindspore_common mindspore_backend
DESTINATION ${INSTALL_LIB_DIR}

View File

@ -108,19 +108,31 @@ elseif(MODE_ASCEND_ACL)
target_link_libraries(mindspore_shared_lib PRIVATE mindspore::grpc++)
endif()
endif()
if(NOT BUILD_LITE)
set_target_properties(mindspore_shared_lib PROPERTIES OUTPUT_NAME mindspore)
endif()
if(ENABLE_D OR ENABLE_GPU)
target_link_libraries(mindspore_shared_lib PRIVATE -Wl,--no-as-needed ${PYTHON_LIBRARIES} ${SECUREC_LIBRARY}
target_link_libraries(mindspore_shared_lib PRIVATE -Wl,--as-needed ${SECUREC_LIBRARY}
mindspore_backend mindspore_core mindspore_common proto_input mindspore::protobuf)
add_library(api_lib SHARED ${CMAKE_CURRENT_SOURCE_DIR}/types.cc
${CMAKE_CURRENT_SOURCE_DIR}/context.cc
${CMAKE_CURRENT_SOURCE_DIR}/cell.cc
${CMAKE_CURRENT_SOURCE_DIR}/serialization.cc
${CMAKE_CURRENT_SOURCE_DIR}/graph/graph.cc
${CMAKE_CURRENT_SOURCE_DIR}/graph/graph_data.cc
${CMAKE_CURRENT_SOURCE_DIR}/model/model.cc
${CMAKE_SOURCE_DIR}/mindspore/core/utils/status.cc
)
target_link_libraries(api_lib PRIVATE mindspore_shared_lib -Wl,--no-as-needed ${PYTHON_LIBRARIES})
set_target_properties(api_lib PROPERTIES OUTPUT_NAME mindspore)
if(CMAKE_SYSTEM_NAME MATCHES "Linux")
set_target_properties(api_lib PROPERTIES INSTALL_RPATH "$ORIGIN")
endif()
else()
if(BUILD_LITE)
target_link_libraries(mindspore_shared_lib PRIVATE mindspore_core ${SECUREC_LIBRARY})
else()
target_link_libraries(mindspore_shared_lib PRIVATE ${PY3_LIBG} ${SECUREC_LIBRARY}
mindspore_backend mindspore mindspore_core mindspore_common proto_input mindspore::protobuf)
set_target_properties(mindspore_shared_lib PROPERTIES OUTPUT_NAME mindspore)
endif()
endif()