Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

reduce wheel size by stripping so libs #1189

Merged
merged 2 commits into from
Apr 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,12 @@ if(NOT EXISTS ${PROTOC_COMMAND})
error() # Place Unknown command to stop cmake process here.
endif()

if (NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE "Release" CACHE STRING
"Build type release is default on single-configuration build system like GNU make."
FORCE)
endif()

###############################################################################
# Preprocessing
###############################################################################
Expand Down Expand Up @@ -178,12 +184,6 @@ if(BUILD_CPP_LIB)
###############################################################################
add_subdirectory(third_party)

if (NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE "Release" CACHE STRING
"Build type release is default on single-configuration build system like GNU make."
FORCE)
endif()

# Flags
if(MSVC)
# Force to always compile with W4
Expand Down Expand Up @@ -373,7 +373,7 @@ if(BUILD_PYTHON_PACKAGE)
COMMAND ${CMAKE_COMMAND} -E env
WHEEL_SUFFIX=${WHEEL_SUFFIX}
${PYTHON_COMMAND} ${NNABLA_CONVERTER_SETUP} -q bdist_wheel
COMMAND ${CMAKE_SOURCE_DIR}/build-tools/auditwheel-nnabla ${CMAKE_BINARY_DIR}/dist/*-linux_*.whl
COMMAND ${CMAKE_SOURCE_DIR}/build-tools/auditwheel-nnabla ${CMAKE_BINARY_DIR}/dist/*-linux_*.whl ${CMAKE_BUILD_TYPE}
COMMAND ${CMAKE_COMMAND} -E remove -f ${CMAKE_BINARY_DIR}/dist/*-linux*.whl
COMMAND ${CMAKE_COMMAND} -E touch ${NBLA_PYTHON_OUTPUT_WHEEL}
DEPENDS ${NBLA_WHEEL_DEPENDS})
Expand Down
14 changes: 13 additions & 1 deletion build-tools/auditwheel-nnabla
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,19 @@ then
cat $WHEEL | sed "s/-linux_/$TAG/g" > $WHEEL.bak && mv $WHEEL.bak $WHEEL
done

INCLUDE_CUDA_CUDNN_LIB_IN_WHL=$2
CMAKE_BUILD_TYPE=$2
# Strip shared libraries.
if [[ "$CMAKE_BUILD_TYPE" != "Debug" ]]; then
for STRIP_LIB in $(find . -name "*.so*")
do
if [[ "$STRIP_LIB" = *"cpython"* ]] || [[ "$STRIP_LIB" = *"libnnabla"* ]] ; then
echo "Striping $STRIP_LIB"
strip --strip-unneeded $STRIP_LIB
fi
done
fi

INCLUDE_CUDA_CUDNN_LIB_IN_WHL=$3
if [[ "$INCLUDE_CUDA_CUDNN_LIB_IN_WHL" == "True" ]]; then
NNABLA_EXT_SO=$(find . -name *libnnabla_cuda*.so)
LIBDIR=$(cd $(dirname $NNABLA_EXT_SO) && pwd)
Expand Down
3 changes: 0 additions & 3 deletions third_party/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,6 @@ endfunction()

if(NNABLA_UTILS_WITH_HDF5)
download_and_extract_library(hdf5-master .zip https://github.com/HDFGroup/hdf5/archive/refs/tags/hdf5-1_12_2.zip DIRECTORY)
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE Release)
endif()
set(HDF5_EXTERNALLY_CONFIGURED, 1)
set(HDF5_EXPORTED_TARGETS "nbla_utils-hdf5-targets")
set(BUILD_SHARED_LIBS ON CACHE BOOL "Build Shared Libraries" FORCE)
Expand Down