Skip to content

Instantly share code, notes, and snippets.

@MattChanTK
Created November 9, 2016 20:53
Show Gist options
  • Select an option

  • Save MattChanTK/b78d808b90645e6c532ec99a7946f862 to your computer and use it in GitHub Desktop.

Select an option

Save MattChanTK/b78d808b90645e6c532ec99a7946f862 to your computer and use it in GitHub Desktop.
#!/bin/bash
#
# ==============================================================================
# Copyright (c) Microsoft. All rights reserved.
# Licensed under the MIT license. See LICENSE.md file in the project root
# for full license information.
# ==============================================================================
# Log steps, stop on error
# TODO cut down on logging
set -x -e -o pipefail
REPO_TAG=v2.0.beta2.0
while [ $# -gt 0 ]; do
case "$1" in
--repo-tag)
REPO_TAG="$2"
[ -z "$REPO_TAG" ] && {
echo Missing value for --repo-tag option.
exit 1
}
shift # extra shift
;;
*)
echo Unknown option $1
exit 1
;;
esac
shift
done
SCRIPT_DIR="$(readlink -f "$(dirname "${BASH_SOURCE[0]}")")"
# Go to the drop root
cd "$SCRIPT_DIR/../.."
CNTK_BIN_PATH="$PWD/cntk/bin"
CNTK_LIB_PATH="$PWD/cntk/lib"
CNTK_DEP_LIB_PATH="$PWD/cntk/dependencies/lib"
CNTK_EXAMPLES_PATH="$PWD/Examples"
CNTK_BINARY="$CNTK_BIN_PATH/cntk"
CNTK_PY34_ENV_FILE="$SCRIPT_DIR/conda-linux-cntk-py34-environment.yml"
CNTK_WHEEL_PATH="cntk/python/cntk-2.0.beta2.0-cp34-cp34m-linux_x86_64.whl"
test -d "$CNTK_BIN_PATH" && test -d "$CNTK_LIB_PATH" && test -d "$CNTK_DEP_LIB_PATH" &&
test -d "$CNTK_EXAMPLES_PATH" && test -x "$CNTK_BINARY" &&
test -f "$CNTK_PY34_ENV_FILE" && test -f "$CNTK_WHEEL_PATH" || {
echo Cannot find expected drop content. Please double-check that this is a
echo CNTK binary drop for Linux. Go to https://github.com/Microsoft/CNTK/wiki
echo for help.
exit 1
}
###########################################
# Clone CNTK repository
CNTK_WORKING_COPY="$HOME/repos/cntk"
if [ -d "$CNTK_WORKING_COPY" ]; then
printf "Path '%s' already exists, skipping CNTK clone\nMake sure to checkout $REPO_TAG\n" "$CNTK_WORKING_COPY"
else
mkdir -p "$HOME/repos"
CNTK_GIT_CLONE_URL=https://github.com/Microsoft/CNTK.git
git clone --branch $REPO_TAG --recursive "$CNTK_GIT_CLONE_URL" "$HOME/repos/cntk"
fi
LD_LIBRARY_PATH_SETTING="$CNTK_LIB_PATH:$CNTK_DEP_LIB_PATH"
if [ "$BUILD_OPENMPI" = "1" ]; then
LD_LIBRARY_PATH_SETTING+=":$OPENMPI_PREFIX/lib"
fi
LD_LIBRARY_PATH_SETTING+=":\$LD_LIBRARY_PATH"
###########################################
# Create an activation script
ACTIVATE_SCRIPT_NAME=activate-cntk
cat >| "$ACTIVATE_SCRIPT_NAME" <<ACTIVATE
if [ -z "\$BASH_VERSION" ]; then
echo Error: only Bash is supported.
elif [ "\$(basename "\$0" 2> /dev/null)" == "$ACTIVATE_SCRIPT_NAME" ]; then
echo Error: this script is meant to be sourced. Run 'source activate-cntk'
else
export PATH="$CNTK_BIN_PATH:\$PATH"
export LD_LIBRARY_PATH="$LD_LIBRARY_PATH_SETTING"
source "$PY_ACTIVATE" "$CNTK_PY34_ENV_PREFIX"
cat <<MESSAGE
************************************************************
CNTK is activated.
Please check out CNTK Python examples in the CNTK repository clone here:
$CNTK_WORKING_COPY/bindings/python/examples
Please check out CNTK Brainscript examples here:
$CNTK_EXAMPLES_PATH
************************************************************
MESSAGE
fi
ACTIVATE
cat <<FINALMESSAGE
************************************************************
CNTK install complete.
To activate the CNTK environment, run
source "$PWD/$ACTIVATE_SCRIPT_NAME"
Please check out CNTK Python examples in the CNTK repository clone here:
$CNTK_WORKING_COPY/bindings/python/examples
Please check out CNTK Brainscript examples here:
$CNTK_EXAMPLES_PATH
************************************************************
FINALMESSAGE
# vim:set expandtab shiftwidth=2 tabstop=2:
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment