提交 f8810f73 编写于 作者: M Megvii Engine Team 提交者: Xinran Xu

feat(mge/imperative): prepare to make whl

GitOrigin-RevId: f9f22fb6cbcfd72331273021b1bea7917a1ddaf8
上级 ff60fdb8
......@@ -79,6 +79,8 @@
```
ALL_PYTHON=35m ./build_wheel.sh cpu
```
Please append `imperative` to `build_wheel.sh` to use the new runtime, e.g., `./build_wheel.sh cpu imperative`.
## build for macos
```
./scripts/whl/macos/macos_build_whl.sh
......
......@@ -6,6 +6,8 @@ OUTPUTDIR=$(readlink -f ${CWD}/output)
USERID=$(id -u)
TMPFS_ARGS="--tmpfs /tmp:exec"
IMPERATIVE=${2:-mgb}
echo ${BASEDIR}
pushd ${BASEDIR}/third_party >/dev/null
./prepare.sh
......@@ -92,6 +94,6 @@ if [ $TENSORRT_VERSION != $REQUIR_TENSORRT_VERSION ] ; then
exit -1
fi
docker run -it --rm $TMPFS_ARGS -e UID=${USERID} -e LOCAL_VERSION=${LOCAL_VERSION} -e ALL_PYTHON=${ALL_PYTHON} -v ${CUDA_ROOT_DIR}:/usr/local/cuda -v ${CUDNN_ROOT_DIR}:/opt/cudnn -v ${TENSORRT_ROOT_DIR}:/opt/tensorrt -v ${BASEDIR}:/home/code -v ${OUTPUTDIR}:/home/output:rw env_manylinux2010:latest /home/code/scripts/whl/manylinux2010/do_build.sh
docker run -it --rm $TMPFS_ARGS -e UID=${USERID} -e LOCAL_VERSION=${LOCAL_VERSION} -e ALL_PYTHON=${ALL_PYTHON} -v ${CUDA_ROOT_DIR}:/usr/local/cuda -v ${CUDNN_ROOT_DIR}:/opt/cudnn -v ${TENSORRT_ROOT_DIR}:/opt/tensorrt -v ${BASEDIR}:/home/code -v ${OUTPUTDIR}:/home/output:rw env_manylinux2010:latest /home/code/scripts/whl/manylinux2010/do_build.sh $IMPERATIVE
......@@ -6,6 +6,15 @@ then
fi
EXTRA_CMAKE_ARGS=
if [[ "$1" == imperative ]]; then
BUILD_IMPERATIVE=ON
SO_NAME=_imperative_rt
SO_PATH=megengine/core
else
BUILD_IMPERATIVE=OFF
SO_NAME=_mgb
SO_PATH=megengine/_internal
fi
for ver in ${ALL_PYTHON}
do
......@@ -14,29 +23,40 @@ do
MAJOR=${python_ver:0:1}
MINOR=${ver:1}
PYTHON_DIR=/opt/python/cp${python_ver}-cp${ver}/
EXT_NAME=_mgb.cpython-${ver}-x86_64-linux-gnu.so
EXT_NAME=${SO_NAME}.cpython-${ver}-x86_64-linux-gnu.so
mkdir -p ${BUILD_DIR}
pushd ${BUILD_DIR} >/dev/null
cmake /home/code -DMGE_WITH_DISTRIBUTED=ON -DMGE_WITH_CUDA=ON \
MGE_CMAKE_FLAGS="-DMGE_WITH_DISTRIBUTED=ON \
-DMGE_WITH_CUDA=ON \
-DCMAKE_PREFIX_PATH=${PYTHON_DIR} \
-DMGE_WITH_TEST=ON -DCMAKE_INSTALL_PREFIX=/home/output \
-DPYTHON_LIBRARY=${PYTHON_DIR}lib/ \
-DPYTHON_INCLUDE_DIR=${PYTHON_DIR}include/python${MAJOR}.${MINOR}/ \
${EXTRA_CMAKE_ARGS}
make -j$(nproc)
-DCMAKE_INSTALL_PREFIX=/home/output "
if [[ "$BUILD_IMPERATIVE" == ON ]]; then
MGE_CMAKE_FLAGS+=" -DMGE_BUILD_IMPERATIVE_RT=ON \
-DPYTHON_EXECUTABLE=${PYTHON_DIR}/bin/python3"
else
MGE_CMAKE_FLAGS+=" -DPYTHON_LIBRARY=${PYTHON_DIR}lib/ \
-DPYTHON_INCLUDE_DIR=${PYTHON_DIR}include/python${MAJOR}.${MINOR}"
fi
cmake /home/code ${MGE_CMAKE_FLAGS} ${EXTRA_CMAKE_ARGS}
make -j$(nproc) VERBOSE=1
make install
mkdir -p staging
mkdir -p /home/output/debug
cp -a python_module/{megengine,setup.py,requires.txt,requires-style.txt,requires-test.txt} staging/
if [[ "$BUILD_IMPERATIVE" == ON ]]; then
cp -a imperative/python/{megengine,setup.py,requires.txt,requires-style.txt,requires-test.txt} staging/
else
cp -a python_module/{megengine,setup.py,requires.txt,requires-style.txt,requires-test.txt} staging/
fi
pushd dnn/cuda-stub/ >/dev/null
strip -s libcuda.so
ln -sf libcuda.so libcuda.so.1
popd >/dev/null
pushd staging >/dev/null
pushd megengine/_internal >/dev/null
objcopy --only-keep-debug _mgb.so ${EXT_NAME}.dbg
strip -s _mgb.so
objcopy --add-gnu-debuglink=${EXT_NAME}.dbg _mgb.so
pushd ${SO_PATH} >/dev/null
SO_NAME_EXT=${SO_NAME}.so
objcopy --only-keep-debug ${SO_NAME_EXT} ${EXT_NAME}.dbg
strip -s ${SO_NAME_EXT}
objcopy --add-gnu-debuglink=${EXT_NAME}.dbg ${SO_NAME_EXT}
cp -a ${EXT_NAME}.dbg /home/output/debug
mkdir -p lib/ucx
cp -L /usr/local/cuda/lib*/libnvrtc-builtins.so lib
......@@ -47,7 +67,12 @@ do
popd >/dev/null
popd >/dev/null
pushd /home/output >/dev/null
LD_LIBRARY_PATH=${BUILD_DIR}/dnn/cuda-stub:$LD_LIBRARY_PATH auditwheel repair -L _internal/lib ${BUILD_DIR}/staging/dist/Meg*.whl
if [[ "$BUILD_IMPERATIVE" == ON ]]; then
NEW_LIB_PATH=core/lib
else
NEW_LIB_PATH=_internal/lib
fi
LD_LIBRARY_PATH=${BUILD_DIR}/dnn/cuda-stub:$LD_LIBRARY_PATH auditwheel repair -L ${NEW_LIB_PATH} ${BUILD_DIR}/staging/dist/Meg*.whl
chown -R ${UID}.${UID} .
popd >/dev/null
rm -rf ${BUILD_DIR}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册