2016-03-09 15:33:06 +03:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
# Copyright (c) Microsoft. All rights reserved.
|
|
|
|
# Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
|
|
|
|
|
|
|
# WARNING. This will run in Microsoft Internal Environment ONLY
|
|
|
|
# Generating CNTK Binary drops in Jenkins environment
|
|
|
|
|
|
|
|
# Stop on Error
|
|
|
|
set -e
|
|
|
|
|
|
|
|
# Define variables to be set via command parameters
|
|
|
|
buildConfig=
|
|
|
|
targetConfig=
|
|
|
|
verbose=false
|
|
|
|
|
|
|
|
# Process Command line parameters
|
|
|
|
|
2016-03-11 15:19:01 +03:00
|
|
|
usage="Usage: make_binary_drop_linux -b build_configuration -t target_configuration [-v] [-h]\nBuild and Target configurations should correspond to Jenkins environment\n-v Verbose output\n-h Displays this message\nExample: make_binary_drop_linux -b Release -t gpu -v"
|
2016-03-09 15:33:06 +03:00
|
|
|
|
|
|
|
if [[ $# == 0 ]]; then
|
2016-03-11 15:19:01 +03:00
|
|
|
echo "Command line parameters are missing" >&2
|
|
|
|
echo -e $usage >&2
|
|
|
|
exit 1
|
2016-03-09 15:33:06 +03:00
|
|
|
fi
|
2016-03-11 15:19:01 +03:00
|
|
|
|
2016-03-09 15:33:06 +03:00
|
|
|
while getopts ":b::t::v" opt; do
|
2016-03-11 15:19:01 +03:00
|
|
|
case $opt in
|
|
|
|
b)
|
|
|
|
# Supposed to be taken from Jenkins BUILD_CONFIGURATION
|
|
|
|
buildConfig=$OPTARG
|
|
|
|
;;
|
|
|
|
t)
|
|
|
|
# Supposed to be taken from Jenkins TARGET_CONFIGURATION
|
|
|
|
targetConfig=$OPTARG
|
|
|
|
;;
|
|
|
|
v)
|
|
|
|
# Enables verbose output
|
|
|
|
verbose=true
|
|
|
|
;;
|
|
|
|
h)
|
|
|
|
# Display Usage message and exit
|
|
|
|
echo -e $usage
|
|
|
|
exit 0
|
|
|
|
;;
|
|
|
|
\?)
|
|
|
|
echo "Invalid parameter: -$OPTARG" >&2
|
|
|
|
echo -e $usage >&2
|
|
|
|
exit 1
|
|
|
|
;;
|
|
|
|
:)
|
|
|
|
echo "Parameter -$OPTARG requires an argument." >&2
|
|
|
|
echo -e $usage >&2
|
|
|
|
exit 1
|
|
|
|
;;
|
|
|
|
esac
|
2016-03-09 15:33:06 +03:00
|
|
|
done
|
|
|
|
|
|
|
|
# Check mandatory parameters presence
|
|
|
|
if [[ -z "$buildConfig" ]]; then
|
2016-03-11 15:19:01 +03:00
|
|
|
echo "Parameter -b is missing." >&2
|
|
|
|
echo -e $usage >&2
|
|
|
|
exit 1
|
2016-03-09 15:33:06 +03:00
|
|
|
fi
|
|
|
|
|
|
|
|
if [[ -z "$targetConfig" ]]; then
|
2016-03-11 15:19:01 +03:00
|
|
|
echo "Parameter -t is missing." >&2
|
|
|
|
echo -e $usage >&2
|
|
|
|
exit 1
|
2016-03-09 15:33:06 +03:00
|
|
|
fi
|
|
|
|
|
|
|
|
# Make buildConfig and targetConfig lowercase
|
2016-03-11 15:19:01 +03:00
|
|
|
buildConfig=$(echo ${buildConfig} | tr '[:upper:]' '[:lower:]')
|
|
|
|
targetConfig=$(echo ${targetConfig} | tr '[:upper:]' '[:lower:]')
|
2016-03-09 15:33:06 +03:00
|
|
|
|
|
|
|
# Enable "verbose" mode if needed
|
|
|
|
# stderr is NOT changed
|
|
|
|
if [[ "$verbose" == true ]]; then
|
2016-03-11 15:19:01 +03:00
|
|
|
exec 3>&1
|
2016-03-09 15:33:06 +03:00
|
|
|
else
|
2016-03-11 15:19:01 +03:00
|
|
|
exec 3>/dev/null
|
2016-03-09 15:33:06 +03:00
|
|
|
fi
|
|
|
|
|
|
|
|
# Define helper function
|
|
|
|
|
|
|
|
# File List Copy function
|
|
|
|
# usage: CopyFilesFromList source_path file_name_array destination_path
|
|
|
|
function CopyFilesFromList ()
|
|
|
|
{
|
2016-03-11 15:19:01 +03:00
|
|
|
declare -a fileNames=(${!2})
|
|
|
|
for fileName in "${fileNames[@]}"
|
|
|
|
do
|
|
|
|
cp "$1/$fileName" "$3"
|
|
|
|
done
|
2016-03-09 15:33:06 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
# Main script
|
|
|
|
|
|
|
|
echo "Making binary drops..." >&3
|
|
|
|
|
|
|
|
# If not a Release build quit
|
|
|
|
if [[ $buildConfig != "release" ]]; then
|
2016-03-11 15:19:01 +03:00
|
|
|
echo "Not a release build. No binary drops generation" >&3
|
|
|
|
exit 0
|
2016-03-09 15:33:06 +03:00
|
|
|
fi
|
|
|
|
|
|
|
|
# Dependency files
|
|
|
|
|
2016-07-06 12:46:31 +03:00
|
|
|
# MKL
|
|
|
|
declare -a mklFiles=("libmkl_cntk_p.so" "libiomp5.so")
|
2016-03-09 15:33:06 +03:00
|
|
|
|
|
|
|
# Open CV
|
2016-07-06 12:46:31 +03:00
|
|
|
declare -a opencvFiles=("libopencv_core.so.3.1" "libopencv_imgproc.so.3.1" "libopencv_imgproc.so.3.1" "libopencv_imgcodecs.so.3.1")
|
2016-03-09 15:33:06 +03:00
|
|
|
|
2016-03-31 21:27:27 +03:00
|
|
|
# libzip
|
|
|
|
declare -a libzipFiles=("libzip.so")
|
|
|
|
|
2016-03-11 15:19:01 +03:00
|
|
|
# CUDA
|
2016-04-18 15:45:48 +03:00
|
|
|
declare -a cudaFiles=("libcudart.so.7.5" "libcublas.so.7.5" "libcurand.so.7.5" "libcusparse.so.7.5")
|
2016-03-09 15:33:06 +03:00
|
|
|
|
|
|
|
# cuDNN
|
|
|
|
declare -a cudnnFiles=("libcudnn.so.4")
|
|
|
|
|
|
|
|
# Set dependency sources paths
|
2016-07-06 12:46:31 +03:00
|
|
|
mklPath="/usr/local/CNTKCustomMKL/1/x64/parallel"
|
|
|
|
opencvPath="/usr/local/opencv-3.1.0/lib"
|
2016-03-31 21:27:27 +03:00
|
|
|
libzipPath="/usr/local/lib"
|
2016-03-09 15:33:06 +03:00
|
|
|
cudaPath="/usr/local/cuda/lib64"
|
|
|
|
cudnnPath="/usr/local/cudnn-4.0/cuda/lib64"
|
|
|
|
|
|
|
|
# Set build paths
|
2016-03-11 15:19:01 +03:00
|
|
|
buildPath="build/$targetConfig/release"
|
2016-03-09 15:33:06 +03:00
|
|
|
basePath="BinaryDrops"
|
2016-03-11 15:19:01 +03:00
|
|
|
baseDropPath="$basePath/cntk"
|
|
|
|
baseBinariesPath="$baseDropPath/cntk"
|
|
|
|
baseDependenciesPath="$baseBinariesPath/dependencies/lib"
|
|
|
|
extrasPath="Tools/cntk-binary-drop/linux/$targetConfig"
|
2016-03-09 15:33:06 +03:00
|
|
|
gzipFile="BinaryDrops.tar.gz"
|
|
|
|
|
|
|
|
# Make BinaryDrops directory
|
|
|
|
mkdir -p $baseBinariesPath
|
|
|
|
|
|
|
|
# Copy build binaries
|
2016-03-11 15:19:01 +03:00
|
|
|
echo "Copying build binaries..." >&3
|
2016-03-09 15:33:06 +03:00
|
|
|
cp -r $buildPath/* $baseBinariesPath
|
|
|
|
|
|
|
|
# Copy Examples
|
|
|
|
echo "Copying Examples..." >&3
|
|
|
|
cp -r Examples $baseDropPath
|
2016-07-06 16:57:25 +03:00
|
|
|
|
|
|
|
# Copy Scripts (Scripts folder from the root of the Repo)
|
|
|
|
echo "Copying Scripts..." >&3
|
|
|
|
cp -r Scripts $baseDropPath
|
2016-07-06 17:32:37 +03:00
|
|
|
# Remove test related file(s) if exist(s)
|
|
|
|
set +e
|
|
|
|
rm $baseDropPath/Scripts/pytest.ini
|
|
|
|
set -e
|
2016-03-09 15:33:06 +03:00
|
|
|
|
|
|
|
# Copy Extras
|
|
|
|
echo "Copying Extras..." >&3
|
|
|
|
cp -r $extrasPath/* $baseDropPath
|
|
|
|
|
|
|
|
# Copy Dependencies
|
|
|
|
echo "Copying Dependencies..." >&3
|
|
|
|
|
|
|
|
# Make dependencies directory
|
|
|
|
mkdir -p $baseDependenciesPath
|
|
|
|
|
2016-07-06 12:46:31 +03:00
|
|
|
# Copy MKL
|
|
|
|
echo "Copying MKL" >&3
|
|
|
|
CopyFilesFromList $mklPath mklFiles[@] $baseDependenciesPath
|
2016-03-09 15:33:06 +03:00
|
|
|
|
|
|
|
# Copy Open CV
|
|
|
|
echo "Copying Open CV..." >&3
|
|
|
|
CopyFilesFromList $opencvPath opencvFiles[@] $baseDependenciesPath
|
|
|
|
|
2016-03-31 21:27:27 +03:00
|
|
|
# Copy libzip
|
|
|
|
echo "Copying libzip..." >&3
|
|
|
|
CopyFilesFromList $libzipPath libzipFiles[@] $baseDependenciesPath
|
|
|
|
|
2016-03-09 15:33:06 +03:00
|
|
|
# GPU Drops only
|
|
|
|
if [[ $targetConfig != "cpu" ]]; then
|
|
|
|
|
2016-03-11 15:19:01 +03:00
|
|
|
# Copy CUDA
|
|
|
|
echo "Copying CUDA..." >&3
|
|
|
|
CopyFilesFromList $cudaPath cudaFiles[@] $baseDependenciesPath
|
2016-03-09 15:33:06 +03:00
|
|
|
|
2016-03-11 15:19:01 +03:00
|
|
|
# Copy cuDNN
|
|
|
|
echo "Copying cuDNN..." >&3
|
|
|
|
CopyFilesFromList $cudnnPath cudnnFiles[@] $baseDependenciesPath
|
2016-03-09 15:33:06 +03:00
|
|
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
echo "Making Archive and cleaning up..." >&3
|
|
|
|
# Make GZipped TAR
|
|
|
|
cd $basePath
|
|
|
|
if [[ "$verbose" == true ]]; then
|
2016-03-11 15:19:01 +03:00
|
|
|
tar -cvzf $gzipFile cntk
|
|
|
|
else
|
|
|
|
tar -czf $gzipFile cntk
|
|
|
|
fi
|
2016-03-09 15:33:06 +03:00
|
|
|
|
|
|
|
# Remove TAR sources
|
|
|
|
rm -r cntk
|