diff --git a/CMakeLists.txt b/CMakeLists.txt index b8e104817d805f806882a97faa224376f56f746f..79764dd5e0bc11dae912bbba1dcc6d8443b2ec70 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -53,11 +53,9 @@ option(MGE_WITH_DISTRIBUTED "Build with distributed support" ON) option(MGE_BUILD_IMPERATIVE_RT "Build _imperative_rt Python Module " ON) option(MGE_BUILD_SDK "Build load_and_run" ON) option(MGE_INFERENCE_ONLY "Build inference only library." OFF) -option(MGE_WITH_PYTHON_MODULE "Build MegEngine legacy Python Module." OFF) option(MGE_WITH_MKLDNN "Enable Intel MKL_DNN support," ON) option(MGE_WITH_ROCM "Enable ROCM support" OFF) - if(NOT ${MGE_BIN_REDUCE} STREQUAL "") message(STATUS "build with BIN REDUCE") if(MGE_WITH_MINIMUM_SIZE) diff --git a/dnn/src/CMakeLists.txt b/dnn/src/CMakeLists.txt index 7bc6934478b3df7c7ae0a020cb8f1f47e739aa80..430a6b946d1d22b470b8a2241d49a5aacae0003f 100644 --- a/dnn/src/CMakeLists.txt +++ b/dnn/src/CMakeLists.txt @@ -184,7 +184,6 @@ if(MGE_WITH_MKLDNN AND ${MGE_ARCH} STREQUAL "x86_64") target_link_libraries(megdnn PRIVATE dnnl) endif() endif() -target_link_libraries(megdnn PRIVATE ${MGE_CUDA_LIBS}) if (BUILD_SHARED_LIBS) target_link_libraries(megdnn PRIVATE $) else() diff --git a/dnn/test/CMakeLists.txt b/dnn/test/CMakeLists.txt index b1ea35146903883fb976c77b9e22bb9566cafa7f..8cfeef2139e2ea08d9a48a71bcb0940c59f067ad 100644 --- a/dnn/test/CMakeLists.txt +++ b/dnn/test/CMakeLists.txt @@ -48,7 +48,7 @@ endif() add_executable(megdnn_test ${SOURCES}) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-narrowing") target_link_libraries(megdnn_test gtest) -target_link_libraries(megdnn_test megdnn ${MGE_BLAS_LIBS}) +target_link_libraries(megdnn_test megdnn ${MGE_BLAS_LIBS} ${MGE_CUDA_LIBS}) if (MGE_WITH_CUDA) target_link_libraries(megdnn_test cutlass) diff --git a/imperative/CMakeLists.txt b/imperative/CMakeLists.txt index 8f3759708df9713f6c2a811e57b564013ea9a069..82b36187c81ea78403bd2820e69d981fa1267a48 100644 --- a/imperative/CMakeLists.txt +++ b/imperative/CMakeLists.txt @@ -28,22 +28,12 @@ if (APPLE) target_link_libraries(${MODULE_NAME} PRIVATE megengine_export) elseif (MSVC OR WIN32) # Windows does not support implicitly importing data members from DLL. - target_link_libraries(${MODULE_NAME} PRIVATE megbrain megdnn) + target_link_libraries(${MODULE_NAME} PRIVATE megbrain megdnn ${MGE_CUDA_LIBS}) message(STATUS "CMAKE_MSVC_RUNTIME_LIBRARY: ${CMAKE_MSVC_RUNTIME_LIBRARY}") set_target_properties(${MODULE_NAME} PROPERTIES MSVC_RUNTIME_LIBRARY "${CMAKE_MSVC_RUNTIME_LIBRARY}") else() - if (MGE_WITH_PYTHON_MODULE) - # use to fix runtime crash when build both mgb(MGE_WITH_PYTHON_MODULE) and imperative(MGE_BUILD_IMPERATIVE_RT) - target_link_libraries(${MODULE_NAME} PRIVATE megengine_export -Wl,--version-script=${MGE_VERSION_SCRIPT}) - else() - # use to reduce whl size by depend on megbrain/dnn directly, caused by cmake create two cuda fatbin - # elf section on both megengine_export and target which depend on megengine_export - target_link_libraries(${MODULE_NAME} PRIVATE megbrain megdnn -Wl,--version-script=${MGE_VERSION_SCRIPT}) - if (MGE_WITH_DISTRIBUTED) - message(VERBOSE "Imperative configured to link megray") - target_link_libraries(${MODULE_NAME} PRIVATE megray) - endif() - endif() + # use to fix runtime crash when build both mgb(MGE_WITH_PYTHON_MODULE) and imperative(MGE_BUILD_IMPERATIVE_RT) + target_link_libraries(${MODULE_NAME} PRIVATE megengine_export -Wl,--version-script=${MGE_VERSION_SCRIPT}) endif() add_subdirectory(${PROJECT_SOURCE_DIR}/third_party/range-v3 ${PROJECT_BINARY_DIR}/third_party/range-v3) diff --git a/imperative/test/CMakeLists.txt b/imperative/test/CMakeLists.txt index 52aec90d40fb80f26f004aa39ec2659ce8b01403..68d0dcecb748ea7f2ed9cd85c8cf7c4447a74c23 100644 --- a/imperative/test/CMakeLists.txt +++ b/imperative/test/CMakeLists.txt @@ -18,7 +18,8 @@ target_include_directories(imperative_test PRIVATE ${MODULE_SRC_INCLUDE} ${PYTHO target_compile_definitions(imperative_test PRIVATE MODULE_NAME=C) target_compile_options(imperative_test PRIVATE -Wno-unused-parameter) -set(LINK_LIBS megbrain megdnn gtest gmock pybind11::embed range-v3) +set(LINK_LIBS megbrain megdnn ${MGE_CUDA_LIBS} gtest gmock pybind11::embed range-v3) + if(MGE_WITH_CUDA) list(APPEND LINK_LIBS cudart) endif() diff --git a/scripts/whl/manylinux2010/do_build.sh b/scripts/whl/manylinux2010/do_build.sh index f79b8ba54394b5358837dbc5cf413c3aecf2c221..1a8e158bc10ce6d5f80697b5eac43dea481ff069 100755 --- a/scripts/whl/manylinux2010/do_build.sh +++ b/scripts/whl/manylinux2010/do_build.sh @@ -34,6 +34,9 @@ function patch_elf_depend_lib() { patchelf --remove-rpath ${BUILD_DIR}/staging/megengine/core/_imperative_rt.so patchelf --force-rpath --set-rpath '$ORIGIN/lib' ${BUILD_DIR}/staging/megengine/core/_imperative_rt.so + cp ${BUILD_DIR}/src/libmegengine_export.so ${LIBS_DIR} + patchelf --remove-rpath ${LIBS_DIR}/libmegengine_export.so + patchelf --force-rpath --set-rpath '$ORIGIN/.' ${LIBS_DIR}/libmegengine_export.so if [ ${BUILD_WHL_CPU_ONLY} = "OFF" ]; then diff --git a/sdk/load-and-run/CMakeLists.txt b/sdk/load-and-run/CMakeLists.txt index 159fa2d6d34a7c0ef16f75417bef0c3714baff6d..4d46b533214799f23ecff84f1378585c524e04ab 100755 --- a/sdk/load-and-run/CMakeLists.txt +++ b/sdk/load-and-run/CMakeLists.txt @@ -4,7 +4,7 @@ add_executable (load_and_run ${SOURCES}) if (WIN32) # Windows does not support implicitly importing data members from DLL. - target_link_libraries(load_and_run megbrain megdnn) + target_link_libraries(load_and_run megbrain megdnn ${MGE_CUDA_LIBS}) else() target_link_libraries (load_and_run megengine) endif() diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index a804f99a79a5f127deba1b66da23cc09f3dfb984..8c0db789c1e2a518eaaed0961be66449e3d5e3c7 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -92,7 +92,6 @@ if(MGE_WITH_DISTRIBUTED) target_include_directories(megbrain PRIVATE ${CPPZMQ_INC} ${CMAKE_CURRENT_BINARY_DIR}) target_link_libraries (megbrain PRIVATE megray) endif() -target_link_libraries(megbrain PRIVATE ${MGE_CUDA_LIBS}) target_link_libraries(megbrain PUBLIC ${MGE_CAMBRICON_LIBS}) target_link_libraries(megbrain PUBLIC ${MGE_ATLAS_LIBS}) if(MGE_WITH_JIT AND MGE_WITH_HALIDE) @@ -189,6 +188,7 @@ if(MGE_BUILD_IMPERATIVE_RT message(VERBOSE "create a export SHARED lib for python use") add_library(megengine_export SHARED) target_link_libraries(megengine_export PUBLIC megbrain megdnn) + target_link_libraries(megengine_export PRIVATE ${MGE_CUDA_LIBS}) if (MGE_WITH_DISTRIBUTED) message(VERBOSE "megengine_export configured to link megray") target_link_libraries(megengine_export PUBLIC megray) @@ -196,6 +196,7 @@ if(MGE_BUILD_IMPERATIVE_RT endif() # Build as SHARED or STATIC depending on BUILD_SHARED_LIBS=ON/OFF add_library(megengine) +target_link_libraries(megengine PRIVATE ${MGE_CUDA_LIBS}) target_link_libraries(megengine PUBLIC megbrain megdnn) if (UNIX AND NOT APPLE) # TODO: Use target_link_options after upgrading to CMake 3.13 diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index eecc194160f6e14b4501367b5fe42d4426511a63..2387a109ce7dceab88f45239cf8ca4c006289bae 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -18,11 +18,7 @@ endif() add_executable(megbrain_test ${SOURCES}) target_link_libraries(megbrain_test gtest gmock) -if(MSVC OR WIN32) - target_link_libraries(megbrain_test megbrain megdnn) -else() - target_link_libraries(megbrain_test megengine) -endif() +target_link_libraries(megbrain_test megbrain megdnn ${MGE_CUDA_LIBS}) if(CXX_SUPPORT_WCLASS_MEMACCESS) if(MGE_WITH_CUDA) target_compile_options(megbrain_test PRIVATE "$<$:-Xcompiler=-Wno-class-memaccess>"