You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

do_build.sh 2.0 kB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. #!/bin/bash -e
  2. ALL_PYTHON=${ALL_PYTHON}
  3. if [[ -z ${ALL_PYTHON} ]]
  4. then
  5. ALL_PYTHON="35m 36m 37m 38"
  6. fi
  7. EXTRA_CMAKE_ARGS=
  8. for ver in ${ALL_PYTHON}
  9. do
  10. python_ver=${ver:0:2}
  11. BUILD_DIR=/tmp/build_megengine/python${python_ver}
  12. MAJOR=${python_ver:0:1}
  13. MINOR=${ver:1}
  14. PYTHON_DIR=/opt/python/cp${python_ver}-cp${ver}/
  15. EXT_NAME=_mgb.cpython-${ver}-x86_64-linux-gnu.so
  16. mkdir -p ${BUILD_DIR}
  17. pushd ${BUILD_DIR} >/dev/null
  18. cmake /home/code -DMGE_WITH_DISTRIBUTED=ON -DMGE_WITH_CUDA=ON \
  19. -DCMAKE_PREFIX_PATH=${PYTHON_DIR} \
  20. -DMGE_WITH_TEST=ON -DCMAKE_INSTALL_PREFIX=/home/output \
  21. -DPYTHON_LIBRARY=${PYTHON_DIR}lib/ \
  22. -DPYTHON_INCLUDE_DIR=${PYTHON_DIR}include/python${MAJOR}.${MINOR}/ \
  23. ${EXTRA_CMAKE_ARGS}
  24. make -j$(nproc)
  25. make install
  26. mkdir -p staging
  27. mkdir -p /home/output/debug
  28. cp -a python_module/{megengine,setup.py} staging/
  29. pushd dnn/cuda-stub/ >/dev/null
  30. strip -s libcuda.so
  31. ln -sf libcuda.so libcuda.so.1
  32. popd >/dev/null
  33. pushd staging >/dev/null
  34. pushd megengine/_internal >/dev/null
  35. objcopy --only-keep-debug _mgb.so ${EXT_NAME}.dbg
  36. strip -s _mgb.so
  37. objcopy --add-gnu-debuglink=${EXT_NAME}.dbg _mgb.so
  38. cp -a ${EXT_NAME}.dbg /home/output/debug
  39. mkdir -p lib/ucx
  40. cp -L /usr/local/cuda/lib*/libnvrtc-builtins.so lib
  41. cp -L ${BUILD_DIR}/third_party/MegRay/third_party/ucx/lib/ucx/*.so lib/ucx/
  42. strip -s lib/ucx/*.so
  43. popd >/dev/null
  44. ${PYTHON_DIR}/bin/python setup.py bdist_wheel
  45. popd >/dev/null
  46. popd >/dev/null
  47. pushd /home/output >/dev/null
  48. LD_LIBRARY_PATH=${BUILD_DIR}/dnn/cuda-stub:$LD_LIBRARY_PATH auditwheel repair -L _internal/lib ${BUILD_DIR}/staging/dist/Meg*.whl
  49. chown -R ${UID}.${UID} .
  50. popd >/dev/null
  51. rm -rf ${BUILD_DIR}
  52. done

MegEngine 安装包中集成了使用 GPU 运行代码所需的 CUDA 环境,不用区分 CPU 和 GPU 版。 如果想要运行 GPU 程序,请确保机器本身配有 GPU 硬件设备并安装好驱动。 如果你想体验在云端 GPU 算力平台进行深度学习开发的感觉,欢迎访问 MegStudio 平台

Contributors (1)