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
OS=$(uname -s)
TAR=tar
13 14 15 16 17

if [[ -z ${MKL_VERSION} ]];then
    MKL_VERSION=2019.5
    MKL_PATCH=281
fi
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
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"
33 34 35

rm -rf mkl

36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51
if [[ -z ${FTP_URL_PREFIX} ]];then
    DOWNLOAD_FILE='${package}-${MKL_VERSION}-intel_${MKL_PATCH}.tar.bz2'
    URL='https://anaconda.org/intel/${package}/${MKL_VERSION}/download/$FILE_PREFIX-${platform}/'${DOWNLOAD_FILE}
else
    DOWNLOAD_FILE='${package}.tar.bz2'
    URL='$FTP_URL_PREFIX/$FILE_PREFIX-${platform}-'${DOWNLOAD_FILE}
fi

for platform in 32 64
do
    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"
52
    do
53 54 55 56
        echo "Installing $(eval echo $DOWNLOAD_FILE) for x86_${platform}..."
        echo "try download mkl package from: $(eval echo $URL)"
        wget -q --show-progress "$(eval echo $URL)" -O mkl/x86_${platform}/"$(eval echo $DOWNLOAD_FILE)"
        $TAR xvj -C mkl/x86_${platform} -f mkl/x86_${platform}/"$(eval echo $DOWNLOAD_FILE)"
57
    done
58
done