install-mkl.sh 1.8 KB
Newer Older
1 2 3 4
#!/bin/bash -e

cd $(dirname $0)

5 6 7 8 9
#FIXME: anaconda just upload serval lastest version, so this version may lose efficacy
echo "this script only for linux/macos/windows-unix-like-env(MSYS etc) prepare MKL env"
echo "if you build windows for native at cmd.exe, powershell env or Visual Studio GUI,"
echo  "u need download MKL package and untar manually"
echo "refs: https://software.intel.com/content/www/us/en/develop/tools/math-kernel-library/choose-download/windows.html"
10 11 12
MKL_VERSION=2019.5
MKL_PATCH=281
CONDA_BASE_URL=https://anaconda.org/intel
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
OS=$(uname -s)
FILE_PREFIX=null
TAR=tar
if [ $OS = "Darwin" ];then
    FILE_PREFIX=osx
elif [ $OS = "Linux" ];then
    FILE_PREFIX=linux
elif [[ $OS =~ "NT" ]]; then
    FILE_PREFIX=win
    # NT use /c/Windows/system32/tar will stuck for big file
    # so we back to GNU tar
    TAR=/usr/bin/tar
else
    echo "DO NOT SUPPORT OS NOW"
    exit -1
fi

echo "config FILE_PREFIX to: $FILE_PREFIX"
31 32 33

rm -rf mkl

34 35 36 37
if [[ -z ${ALREADY_INSTALL_MKL} ]]
then
    echo "init mkl from software.intel.com"
    for platform in 32 64
38
    do
39 40 41 42 43 44 45 46 47 48 49 50 51 52
        if [ $OS = "Darwin" ]&&[ $platform = 32 ];then
            echo "strip 32 bit file for Darwin"
            continue
        fi
        mkdir -p mkl/x86_${platform}
        for package in "mkl-include" "mkl-static"
        do
            DOWNLOAD_FILE=${package}-${MKL_VERSION}-intel_${MKL_PATCH}.tar.bz2
            echo "Installing ${DOWNLOAD_FILE} for x86_${platform}..."
            URL=${CONDA_BASE_URL}/${package}/${MKL_VERSION}/download/$FILE_PREFIX-${platform}/${DOWNLOAD_FILE}
            echo "try download mkl package from: ${URL}"
            wget -q --show-progress "${URL}" -O mkl/x86_${platform}/${DOWNLOAD_FILE}
            $TAR xvj -C mkl/x86_${platform} -f mkl/x86_${platform}/${DOWNLOAD_FILE}
        done
53
    done
54
fi