From 3a2127779881519852d0806f88b0435bde7540f4 Mon Sep 17 00:00:00 2001 From: Hui Zhang Date: Tue, 6 Jul 2021 03:29:05 +0000 Subject: [PATCH] fix install scripts --- tools/install/install_gcc.sh | 2 + tools/install/install_kaldi.sh | 5 +- tools/install/install_mfa.sh | 4 +- tools/install/install_mkl.sh | 363 +++++++++++++++++-------------- tools/install/install_ngram.sh | 7 + tools/install/install_openfst.sh | 10 +- tools/install/install_pynini.sh | 11 +- 7 files changed, 228 insertions(+), 174 deletions(-) diff --git a/tools/install/install_gcc.sh b/tools/install/install_gcc.sh index 6eda8ea7..eb4ea1f0 100755 --- a/tools/install/install_gcc.sh +++ b/tools/install/install_gcc.sh @@ -1,3 +1,5 @@ +#!/bin/bash + set -e set -x diff --git a/tools/install/install_kaldi.sh b/tools/install/install_kaldi.sh index 545fbe4e..b87232b0 100755 --- a/tools/install/install_kaldi.sh +++ b/tools/install/install_kaldi.sh @@ -27,8 +27,9 @@ touch "python/.use_default_python" make -j4 -cd ../src -./configure --shared --use-cuda=no --static-math +pushd ../src +./configure --shared --use-cuda=no --static-math --mathlib=OPENBLAS --openblas-root=${KALDI_DIR}/../OpenBLAS/install make clean -j && make depend -j && make -j4 +popd echo "Done installing Kaldi." diff --git a/tools/install/install_mfa.sh b/tools/install/install_mfa.sh index fdcdaa94..b0a4cf99 100755 --- a/tools/install/install_mfa.sh +++ b/tools/install/install_mfa.sh @@ -1,8 +1,10 @@ #!/bin/bash +# install openblas, kaldi before + test -d Montreal-Forced-Aligner || git clone https://github.com/MontrealCorpusTools/Montreal-Forced-Aligner.git -pushd Montreal-Forced-Aligner && python setup.py install +pushd Montreal-Forced-Aligner && git checkout v2.0.0a7 && python setup.py install test -d kaldi || { echo "need install kaldi first"; exit 1;} diff --git a/tools/install/install_mkl.sh b/tools/install/install_mkl.sh index 84fdc9c3..8c1899bd 100755 --- a/tools/install/install_mkl.sh +++ b/tools/install/install_mkl.sh @@ -19,42 +19,47 @@ apt_repo='https://apt.repos.intel.com/mkl' intel_key_url='https://apt.repos.intel.com/intel-gpg-keys/GPG-PUB-KEY-INTEL-SW-PRODUCTS-2019.PUB' Usage () { - cat >&2 <] - Checks if MKL is present on the system, and/or attempts to install it. - If is not provided, ${default_package} will be installed. - Intel packages are installed under the /opt/intel directory. You should be root - to install MKL into this directory; run this script using the sudo command. - Options: - -s - Skip check for MKL being already present. - -p -- Force type of package management. Use only - if automatic detection fails, as instructed. - -h - Show this message. - Environment: - CC The C compiler to use for MKL check. If not set, uses 'cc'. - EOF - exit 2 - } - - Fatal () { echo "$0: $@"; exit 1; } - - Have () { type -t "$1" >/dev/null; } - - # Option values. - skip_cc= - distro= - - while getopts ":hksp:" opt; do - case ${opt} in - h) Usage ;; - s) skip_cc=yes ;; - p) case $OPTARG in - suse|redhat|debian|fedora|arch) distro=$OPTARG ;; - *) Fatal "invalid value -p '${OPTARG}'. " \ - "Allowed: 'suse', 'redhat', 'debian', 'fedora', or 'arch'." - esac ;; - \?) echo >&2 "$0: invalid option -${OPTARG}."; Usage ;; - esac + cat >&2 <] + +Checks if MKL is present on the system, and/or attempts to install it. + +If is not provided, ${default_package} will be installed. + +Intel packages are installed under the /opt/intel directory. You should be root +to install MKL into this directory; run this script using the sudo command. + +Options: + -s - Skip check for MKL being already present. + -p -- Force type of package management. Use only + if automatic detection fails, as instructed. + -h - Show this message. + +Environment: + CC The C compiler to use for MKL check. If not set, uses 'cc'. +EOF + exit 2 +} + +Fatal () { echo "$0: $@"; exit 1; } + +Have () { type -t "$1" >/dev/null; } + +# Option values. +skip_cc= +distro= + +while getopts ":hksp:" opt; do + case ${opt} in + h) Usage ;; + s) skip_cc=yes ;; + p) case $OPTARG in + suse|redhat|debian|fedora|arch) distro=$OPTARG ;; + *) Fatal "invalid value -p '${OPTARG}'. " \ + "Allowed: 'suse', 'redhat', 'debian', 'fedora', or 'arch'." + esac ;; + \?) echo >&2 "$0: invalid option -${OPTARG}."; Usage ;; + esac done shift $((OPTIND-1)) @@ -63,178 +68,210 @@ package=${1:-$default_package} # Check that we are actually on Linux, otherwise give a helpful reference. [[ $(uname) == Linux ]] || Fatal "\ - This script can be used on Linux only, and your system is $(uname). +This script can be used on Linux only, and your system is $(uname). + Installer packages for Mac and Windows are available for download from Intel: https://software.intel.com/mkl/choose-download" # Test if MKL is already installed on the system. if [[ ! $skip_cc ]]; then - : ${CC:=cc} - Have "$CC" || Fatal "\ - C compiler $CC not found. - You can skip the check for MKL presence by invoking this script with the '-s' - option to this script, but you will need a functional compiler anyway, so we - recommend that you install it first." - - mkl_version=$($CC -E -I /opt/intel/mkl/include - <<< \ - '#include - __INTEL_MKL__.__INTEL_MKL_MINOR__.__INTEL_MKL_UPDATE__' 2>/dev/null | - tail -n 1 ) || mkl_version= - mkl_version=${mkl_version// /} - [[ $mkl_version ]] && Fatal "\ - MKL version $mkl_version is already installed. - You can skip the check for MKL presence by invoking this script with the '-s' - option and proceed with automated installation, but we highly discourage - this. This script will register Intel repositories with your system, and it - seems that they have been already registered, or MKL has been installed some - other way. - You should use your package manager to check which MKL package is already - installed. Note that Intel packages register the latest installed version of - the library as the default. If your installed version is older than - $package, it makes sense to upgrade." + : ${CC:=cc} + Have "$CC" || Fatal "\ +C compiler $CC not found. + +You can skip the check for MKL presence by invoking this script with the '-s' +option to this script, but you will need a functional compiler anyway, so we +recommend that you install it first." + + mkl_version=$($CC -E -I /opt/intel/mkl/include - <<< \ + '#include + __INTEL_MKL__.__INTEL_MKL_MINOR__.__INTEL_MKL_UPDATE__' 2>/dev/null | + tail -n 1 ) || mkl_version= + mkl_version=${mkl_version// /} + + [[ $mkl_version ]] && Fatal "\ +MKL version $mkl_version is already installed. + +You can skip the check for MKL presence by invoking this script with the '-s' +option and proceed with automated installation, but we highly discourage +this. This script will register Intel repositories with your system, and it +seems that they have been already registered, or MKL has been installed some +other way. + +You should use your package manager to check which MKL package is already +installed. Note that Intel packages register the latest installed version of +the library as the default. If your installed version is older than +$package, it makes sense to upgrade." fi + # Try to determine which package manager the distro uses, unless overridden. if [[ ! $distro ]]; then - dist_vars=$(cat /etc/os-release 2>/dev/null) - eval "$dist_vars" - for rune in $CPE_NAME $ID $ID_LIKE; do - case "$rune" in - cpe:/o:fedoraproject:fedora:2[01]) distro=redhat; break;; # Use yum. - rhel|centos) distro=redhat; break;; - redhat|suse|fedora|debian|arch) distro=$rune; break;; - esac - done - # Certain old distributions do not have /etc/os-release. We are unlikely to - # encounter these in the wild, but just in case. - # NOTE: Do not try to guess Fedora specifically here! Fedora 20 and below - # detect as redhat, and this is good, because they use yum by default. - [[ ! $distro && -f /etc/redhat-release ]] && distro=redhat - [[ ! $distro && -f /etc/SuSE-release ]] && distro=suse - [[ ! $distro && -f /etc/debian_release ]] && distro=debian - [[ ! $distro && -f /etc/arch-release ]] && distro=arch - [[ ! $distro ]] && Fatal "\ - Unable to determine package management style. - Invoke this script with the option '-p