Browse Source

fix(whl/linux): reduce external megengine whl package size

GitOrigin-RevId: 3528af8bae
release-1.1
Megvii Engine Team 4 years ago
parent
commit
26e473e769
3 changed files with 15 additions and 2 deletions
  1. +2
    -0
      CMakeLists.txt
  2. +12
    -1
      imperative/CMakeLists.txt
  3. +1
    -1
      src/CMakeLists.txt

+ 2
- 0
CMakeLists.txt View File

@@ -53,9 +53,11 @@ 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("build with BIN REDUCE")
if(MGE_WITH_MINIMUM_SIZE)


+ 12
- 1
imperative/CMakeLists.txt View File

@@ -60,7 +60,18 @@ elseif (MSVC OR WIN32)
message("-- CMAKE_MSVC_RUNTIME_LIBRARY: ${CMAKE_MSVC_RUNTIME_LIBRARY}")
set_target_properties(${MODULE_NAME} PROPERTIES MSVC_RUNTIME_LIBRARY "${CMAKE_MSVC_RUNTIME_LIBRARY}")
else()
target_link_libraries(${MODULE_NAME} PRIVATE megengine_export -Wl,--version-script=${VERSION_SCRIPT})
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=${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=${VERSION_SCRIPT})
if (MGE_WITH_DISTRIBUTED)
message("-- Imperative configured to link megray")
target_link_libraries(${MODULE_NAME} PRIVATE megray)
endif()
endif()
endif()

target_include_directories(${MODULE_NAME} PUBLIC src/include PRIVATE ${PYTHON_INCLUDE_DIRS} ${NUMPY_INCLUDE_DIR})


+ 1
- 1
src/CMakeLists.txt View File

@@ -189,7 +189,7 @@ if(MGE_BUILD_IMPERATIVE_RT
add_library(megengine_export SHARED)
target_link_libraries(megengine_export PUBLIC megbrain megdnn)
if (MGE_WITH_DISTRIBUTED)
message("megengine_export configured to link megray")
message("-- megengine_export configured to link megray")
target_link_libraries(megengine_export PUBLIC megray)
endif()
endif()


Loading…
Cancel
Save