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.

macos_whl_env_prepare.sh 3.5 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. #!/bin/bash -e
  2. #install env before use greadlink
  3. function try_install_brew() {
  4. which brew
  5. if [ $? -eq 0 ]; then
  6. echo "find install brew, use it"
  7. else
  8. echo "DO NOT FIND brew, now try install, may ask root password, please input manually!!"
  9. /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"
  10. #try double check
  11. which brew
  12. if [ $? -eq 0 ]; then
  13. echo "find install brew, use it"
  14. else
  15. echo "ERR: INSTALL brew failed!!, please install manually!!"
  16. exit -1
  17. fi
  18. fi
  19. }
  20. function install_brew_package() {
  21. BREW_PACKAGE="openssl readline sqlite3 xz gdbm zlib pyenv wget swig coreutils llvm git-lfs"
  22. for pak in ${BREW_PACKAGE}
  23. do
  24. echo "###### do command: brew install ${pak}"
  25. brew install ${pak}
  26. done
  27. git lfs install
  28. }
  29. try_install_brew
  30. install_brew_package
  31. READLINK=readlink
  32. OS=$(uname -s)
  33. if [ $OS = "Darwin" ];then
  34. READLINK=greadlink
  35. else
  36. echo "ERR: only run at macos env"
  37. exit -1
  38. fi
  39. SRC_DIR=$($READLINK -f "`dirname $0`/../../../")
  40. echo ${SRC_DIR}
  41. ALL_PYTHON="3.5.9 3.6.10 3.7.7 3.8.3"
  42. function install_python_package() {
  43. for pak in ${ALL_PYTHON}
  44. do
  45. echo "###### do command: env PYTHON_CONFIGURE_OPTS=\"--enable-shared\" pyenv install ${pak}"
  46. if [ -e /Users/$USER/.pyenv/versions/${pak} ];then
  47. echo "FOUND install /Users/$USER/.pyenv/versions/${pak} strip it..."
  48. else
  49. env PYTHON_CONFIGURE_OPTS="--enable-shared" pyenv install ${pak}
  50. fi
  51. echo "###### do command: /Users/${USER}/.pyenv/versions/${pak}/bin/python3 -m pip install numpy wheel requests tqdm tabulate"
  52. /Users/${USER}/.pyenv/versions/${pak}/bin/python3 -m pip install numpy wheel
  53. echo "###### do command: /Users/${USER}/.pyenv/versions/${pak}/bin/python3 -m pip install -r ${SRC_DIR}/python_module/requires-test.txt"
  54. /Users/${USER}/.pyenv/versions/${pak}/bin/python3 -m pip install -r ${SRC_DIR}/python_module/requires-test.txt
  55. done
  56. }
  57. function install_cmake() {
  58. CMAKE_INSTALL_DIR="/Users/${USER}/megengine_use_cmake"
  59. if [ -f /Users/${USER}/megengine_use_cmake/install/bin/cmake ];then
  60. echo "find old build cmake, strip..."
  61. else
  62. if [ ! -d /Users/${USER}/megengine_use_cmake ];then
  63. echo "create dir for megengine_use_cmake"
  64. mkdir -p ${CMAKE_INSTALL_DIR}
  65. fi
  66. rm -rf ${CMAKE_INSTALL_DIR}/src/cmake-3.14.4.tar.gz
  67. mkdir ${CMAKE_INSTALL_DIR}/src
  68. cd ${CMAKE_INSTALL_DIR}/src
  69. wget https://cmake.org/files/v3.14/cmake-3.14.4.tar.gz
  70. tar -xvf cmake-3.14.4.tar.gz
  71. cd cmake-3.14.4
  72. mkdir build
  73. cd build
  74. ../configure --prefix=${CMAKE_INSTALL_DIR}/install
  75. make -j$(nproc)
  76. make install
  77. fi
  78. }
  79. function append_path_env_message() {
  80. echo "+++++++++++++++++++++++++++++++++++++++++++++++++++++"
  81. echo "install env build megengine macos env successfully"
  82. echo "pls append path env at build script, if u use customization whl build script"
  83. echo "append detail:"
  84. echo "/Users/${USER}/megengine_use_cmake/install/bin/"
  85. echo "/usr/local/opt/findutils/libexec/gnubin"
  86. echo "/usr/local/opt/binutils/bin"
  87. echo "/usr/local/opt/llvm/bin"
  88. echo "+++++++++++++++++++++++++++++++++++++++++++++++++++++"
  89. }
  90. ############install env now###########
  91. install_python_package
  92. install_cmake
  93. append_path_env_message

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