Skip to content

Instantly share code, notes, and snippets.

@treo
Forked from crockpotveggies/build-dl4j-stack.sh
Last active June 7, 2017 22:36
Show Gist options
  • Save treo/6e243d616ba1ff8ac201444f8e910471 to your computer and use it in GitHub Desktop.
Save treo/6e243d616ba1ff8ac201444f8e910471 to your computer and use it in GitHub Desktop.
Script that cleanly builds and locally installs the Deeplearning4j stack
#!/bin/bash
# helper function that ensures cmd returns 0 exit code
function checkexit {
"$@"
local status=$?
if [ $status -ne 0 ]; then
echo "error with $1" >&2
exit 1
fi
return $status
}
# check incoming parameters
while [[ $# > 1 ]]
do
key="$1"
#Build type (release/debug), packaging type, chip: cpu,gpu,lib type (static/dynamic)
case $key in
-b|--build-type)
BUILD="$2"
shift # past argument
;;
-p|--packaging)
PACKAGING="$2"
shift # past argument
;;
-c|--chip)
CHIP="$2"
shift # past argument
;;
-l|--libtype)
LIBTYPE="$2"
shift # past argument
;;
--scalav)
SCALAV="$2"
shift # past argument
;;
--default)
DEFAULT=YES
;;
*)
# unknown option
;;
esac
shift # past argument or value
done
# default for chip
if [ -z "$CHIP" ]; then
CHIP="cpu"
fi
# adjust scala versions
if [ "$SCALAV" == "2.10" ]; then
SCALA="2.10.6"
fi
# adjust scala versions
if [ "$SCALAV" == "2.11" ]; then
SCALA="2.11.7"
fi
# removes any existing repositories to ensure a clean build
find . -maxdepth 1 -iname "libnd4j" -exec rm -rf "{}" \;
find . -maxdepth 1 -iname "nd4j" -exec rm -rf "{}" \;
find . -maxdepth 1 -iname "datavec" -exec rm -rf "{}" \;
find . -maxdepth 1 -iname "deeplearning4j" -exec rm -rf "{}" \;
# compile libnd4j
checkexit git clone https://github.com/deeplearning4j/libnd4j.git
cd libnd4j
checkexit bash buildnativeoperations.sh "$@"
#bash buildnativeoperations.sh -c cuda
export LIBND4J_HOME=`pwd`
cd ..
# build and install nd4j to maven locally
checkexit git clone https://github.com/deeplearning4j/nd4j.git
cd nd4j
if [ "$CHIP" == "cpu" ]; then
checkexit mvn clean install -DskipTests -Dmaven.javadoc.skip=true -pl '!:nd4j-cuda-7.5,!:nd4j-cuda-7.5-platform,!:nd4j-tests'
else
checkexit mvn clean install -DskipTests -Dmaven.javadoc.skip=true -pl '!:nd4j-tests'
fi
cd ..
# build and install datavec
checkexit git clone https://github.com/deeplearning4j/datavec.git
cd datavec
if [ "$SCALAV" == "" ]; then
checkexit bash buildmultiplescalaversions.sh clean install -DskipTests -Dmaven.javadoc.skip=true
else
checkexit mvn clean install -DskipTests -Dmaven.javadoc.skip=true -Dscala.binary.version=$SCALAV -Dscala.version=$SCALA
fi
cd ..
# build and install deeplearning4j
checkexit git clone https://github.com/deeplearning4j/deeplearning4j.git
cd deeplearning4j
if [ "$SCALAV" == "" ]; then
checkexit bash buildmultiplescalaversions.sh clean install -DskipTests -Dmaven.javadoc.skip=true
else
checkexit mvn clean install -DskipTests -Dmaven.javadoc.skip=true -Dscala.binary.version=$SCALAV -Dscala.version=$SCALA
fi
cd ..
@dan-lind
Copy link

Should remove canova from the script, and add
find . -maxdepth 1 -iname "datavec" -exec rm -rf "{}" ;
for clean build

@crockpotveggies
Copy link

Cuda version also needs updating. I've updated my original build script for the time being.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment