install_deps_embd.sh 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. #!/usr/bin/env bash
  2. # Licensed to the LF AI & Data foundation under one
  3. # or more contributor license agreements. See the NOTICE file
  4. # distributed with this work for additional information
  5. # regarding copyright ownership. The ASF licenses this file
  6. # to you under the Apache License, Version 2.0 (the
  7. # "License"); you may not use this file except in compliance
  8. # with the License. You may obtain a copy of the License at
  9. #
  10. # http://www.apache.org/licenses/LICENSE-2.0
  11. #
  12. # Unless required by applicable law or agreed to in writing, software
  13. # distributed under the License is distributed on an "AS IS" BASIS,
  14. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  15. # See the License for the specific language governing permissions and
  16. # limitations under the License.
  17. function install_linux_deps() {
  18. if [[ -x "$(command -v apt)" ]]; then
  19. # for Ubuntu 20.04
  20. sudo apt install -y g++ gcc make ccache libssl-dev zlib1g-dev libboost-regex-dev \
  21. libboost-program-options-dev libboost-system-dev libboost-filesystem-dev \
  22. libboost-serialization-dev python3-dev libboost-python-dev libcurl4-openssl-dev gfortran libtbb-dev libzstd-dev
  23. # install OpenBLAS, this could take a while.
  24. wget https://github.com/xianyi/OpenBLAS/archive/v0.3.9.tar.gz && \
  25. tar zxvf v0.3.9.tar.gz && cd OpenBLAS-0.3.9 && \
  26. sudo make TARGET=CORE2 DYNAMIC_ARCH=1 DYNAMIC_OLDER=1 USE_THREAD=0 USE_OPENMP=0 FC=gfortran CC=gcc COMMON_OPT="-O3 -g -fPIC" FCOMMON_OPT="-O3 -g -fPIC -frecursive" NMAX="NUM_THREADS=128" LIBPREFIX="libopenblas" INTERFACE64=0 NO_STATIC=1 && \
  27. sudo make PREFIX=/usr NO_STATIC=1 install && \
  28. cd .. && rm -rf OpenBLAS-0.3.9 && rm v0.3.9.tar.gz
  29. elif [[ -x "$(command -v yum)" ]]; then
  30. # for CentOS 7
  31. sudo yum install -y epel-release centos-release-scl-rh && \
  32. sudo yum install -y git make automake ccache openssl-devel zlib-devel libzstd-devel \
  33. libcurl-devel python3-devel \
  34. devtoolset-11-gcc devtoolset-11-gcc-c++ devtoolset-11-gcc-gfortran \
  35. llvm-toolset-11.0-clang llvm-toolset-11.0-clang-tools-extra
  36. echo "source scl_source enable devtoolset-11" | sudo tee -a /etc/profile.d/devtoolset-11.sh
  37. echo "source scl_source enable llvm-toolset-11.0" | sudo tee -a /etc/profile.d/llvm-toolset-11.sh
  38. echo "export CLANG_TOOLS_PATH=/opt/rh/llvm-toolset-11.0/root/usr/bin" | sudo tee -a /etc/profile.d/llvm-toolset-11.sh
  39. source "/etc/profile.d/llvm-toolset-11.sh"
  40. # install OpenBLAS, this could take a while.
  41. source "/etc/profile.d/devtoolset-11.sh" && \
  42. wget https://github.com/xianyi/OpenBLAS/archive/v0.3.9.tar.gz && \
  43. tar zxvf v0.3.9.tar.gz && cd OpenBLAS-0.3.9 && \
  44. make TARGET=CORE2 DYNAMIC_ARCH=1 DYNAMIC_OLDER=1 USE_THREAD=0 USE_OPENMP=0 FC=gfortran CC=gcc COMMON_OPT="-O3 -g -fPIC" FCOMMON_OPT="-O3 -g -fPIC -frecursive" NMAX="NUM_THREADS=128" LIBPREFIX="libopenblas" INTERFACE64=0 NO_STATIC=1 && \
  45. make PREFIX=/usr NO_STATIC=1 install && \
  46. cd .. && rm -rf OpenBLAS-0.3.9 && rm v0.3.9.tar.gz
  47. # Install tbb
  48. git clone https://github.com/wjakob/tbb.git && \
  49. cd tbb/build && \
  50. cmake .. && make -j && \
  51. sudo make install && \
  52. cd ../../ && rm -rf tbb/
  53. # Install boost
  54. wget -q https://boostorg.jfrog.io/artifactory/main/release/1.65.1/source/boost_1_65_1.tar.gz && \
  55. tar zxf boost_1_65_1.tar.gz && cd boost_1_65_1 && \
  56. ./bootstrap.sh --prefix=/usr/local --with-toolset=gcc --without-libraries=python && \
  57. sudo ./b2 -j2 --prefix=/usr/local --without-python toolset=gcc install && \
  58. cd ../ && rm -rf ./boost_1_65_1*
  59. else
  60. echo "Error Install Dependencies ..."
  61. exit 1
  62. fi
  63. }
  64. function install_mac_deps() {
  65. sudo xcode-select --install > /dev/null 2>&1
  66. brew install boost libomp ninja tbb cmake llvm ccache zstd
  67. brew uninstall grep
  68. brew install grep
  69. export PATH="/usr/local/opt/grep/libexec/gnubin:$PATH"
  70. brew update && brew upgrade && brew cleanup
  71. if [[ $(arch) == 'arm64' ]]; then
  72. sudo mkdir /usr/local/include
  73. sudo mkdir /usr/local/opt
  74. sudo ln -s "$(brew --prefix llvm)" "/usr/local/opt/llvm"
  75. sudo ln -s "$(brew --prefix libomp)/include/omp.h" "/usr/local/include/omp.h"
  76. sudo ln -s "$(brew --prefix libomp)" "/usr/local/opt/libomp"
  77. sudo ln -s "$(brew --prefix boost)/include/boost" "/usr/local/include/boost"
  78. sudo ln -s "$(brew --prefix tbb)/include/tbb" "/usr/local/include/tbb"
  79. sudo ln -s "$(brew --prefix tbb)/include/oneapi" "/usr/local/include/oneapi"
  80. fi
  81. }
  82. unameOut="$(uname -s)"
  83. case "${unameOut}" in
  84. Linux*) install_linux_deps;;
  85. Darwin*) install_mac_deps;;
  86. *) echo "Unsupported OS:${unameOut}" ; exit 0;
  87. esac