This repository has been archived by the owner on Apr 3, 2019. It is now read-only.
forked from deeplearning4j/deeplearning4j
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build-dl4j-stack.sh
executable file
·229 lines (213 loc) · 5.64 KB
/
build-dl4j-stack.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
#!/bin/bash -e
# 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 [[ $# -gt 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
;;
-cc|--compute)
COMPUTE="$2"
shift # past argument
;;
-a|--march)
NATIVE="$2"
shift # past argument
;;
-l|--libtype)
LIBTYPE="$2"
shift # past argument
;;
--scalav)
SCALAV="$2"
shift # past argument
;;
-s|--shallow)
SHALLOW="YES"
;;
-d|--delete-repos)
DELETE_REPOS="YES"
;;
--testnd4j)
TEST_ND4J="YES"
;;
--testdatavec)
TEST_DATAVEC="YES"
;;
--testdl4j)
TEST_DL4J="YES"
;;
--mvnopts)
MVN_OPTS="$2"
shift
;;
*)
# unknown option
;;
esac
shift # past argument or value
done
# default for chip
if [ -z "$CHIP" ]; then
# test for cuda libraries
if (ldconfig -p | grep -q libcuda\.so) then
CHIP="cuda"
else
CHIP="cpu"
fi
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
# set git cloning to a shallow depth if the option says so
if [ -z $SHALLOW ]; then
GIT_CLONE="git clone"
else
GIT_CLONE="git clone --depth 1"
fi
# Report argument values
echo BUILD = "${BUILD}"
echo PACKAGING = "${PACKAGING}"
echo CHIP = "${CHIP}"
echo COMPUTE = "${COMPUTE}"
echo NATIVE = "${NATIVE}"
echo LIBTYPE = "${LIBTYPE}"
echo SCALAV = "${SCALAV}"
echo SHALLOW = "${SHALLOW}"
echo DELETE_REPOS = "${DELETE_REPOS}"
echo TEST_ND4J = "${TEST_ND4J}"
echo TEST_DATAVEC = "${TEST_DATAVEC}"
echo TEST_DL4J = "${TEST_DL4J}"
echo MVN_OPTS = "${MVN_OPTS}"
###########################
# Script execution starts #
###########################
pushd ..
# removes lingering snapshot artifacts from existing maven cache to ensure a
# clean build
JAVA_PROJECTS="nd4j datavec deeplearning4j"
for dirName in $JAVA_PROJECTS; do
if [ -d "$dirName" ]; then
pushd "$dirName"
mvn dependency:purge-local-repository -DreResolve=false
popd
fi
done
# removes any existing repositories to ensure a clean build
if ! [ -z "$DELETE_REPOS" ]; then
PROJECTS="libnd4j nd4j datavec deeplearning4j"
for dirName in $PROJECTS; do
find . -maxdepth 1 -iname "$dirName" -exec rm -rf "{}" \;
done
fi
# compile libnd4j
if ! [ -z $DELETE_REPOS ] || ! [ -d libnd4j ]; then
checkexit $GIT_CLONE https://github.com/deeplearning4j/libnd4j.git
fi
pushd libnd4j
if [ -z "$NATIVE" ]; then
checkexit bash buildnativeoperations.sh "$@" -a native
else
checkexit bash buildnativeoperations.sh "$@"
fi
if [ "$CHIP" == "cuda" ]; then
if [ -z "$COMPUTE" ]; then
checkexit bash buildnativeoperations.sh -c cuda
else
checkexit bash buildnativeoperations.sh -c cuda -cc "$COMPUTE"
fi
fi
LIBND4J_HOME=$(pwd)
export LIBND4J_HOME
popd
# build and install nd4j to maven locally
if ! [ -z $DELETE_REPOS ] || ! [ -d nd4j ]; then
checkexit $GIT_CLONE https://github.com/deeplearning4j/nd4j.git
fi
if [ -z "$TEST_ND4J" ]; then
ND4J_OPTIONS="-DskipTests"
else
ND4J_OPTIONS=""
fi
pushd nd4j
if [ "$CHIP" == "cpu" ]; then
checkexit bash buildmultiplescalaversions.sh clean install -Dmaven.javadoc.skip=true -pl '!:nd4j-cuda-8.0,!:nd4j-cuda-8.0-platform,!:nd4j-tests' $ND4J_OPTIONS $MVN_OPTS
else
checkexit bash buildmultiplescalaversions.sh clean install -Dmaven.javadoc.skip=true $ND4J_OPTIONS $MVN_OPTS
fi
popd
# build and install datavec
if ! [ -z $DELETE_REPOS ] || ! [ -d datavec ]; then
checkexit $GIT_CLONE https://github.com/deeplearning4j/datavec.git
fi
if [ -z "$TEST_DATAVEC" ]; then
DATAVEC_OPTIONS="-DskipTests"
else
if [ "$CHIP" == "cuda" ]; then
DATAVEC_OPTIONS="-Ptest-nd4j-cuda-8.0"
else
DATAVEC_OPTIONS="-Ptest-nd4j-native"
fi
fi
pushd datavec
if [ "$SCALAV" == "" ]; then
checkexit bash buildmultiplescalaversions.sh clean install -Dmaven.javadoc.skip=true $DATAVEC_OPTIONS $MVN_OPTS
else
checkexit mvn clean install -Dmaven.javadoc.skip=true -Dscala.binary.version="$SCALAV" -Dscala.version="$SCALA" $DATAVEC_OPTIONS $MVN_OPTS
fi
popd
# build and install deeplearning4j
if ! [ -z $DELETE_REPOS ] || ! [ -d deeplearning4j ]; then
checkexit $GIT_CLONE https://github.com/deeplearning4j/deeplearning4j.git
fi
if [ -z "$TEST_DL4J" ]; then
DL4J_OPTIONS="-DskipTests"
else
if [ "$CHIP" == "cuda" ]; then
DL4J_OPTIONS="-Ptest-nd4j-cuda-8.0"
else
DL4J_OPTIONS="-Ptest-nd4j-native"
fi
fi
pushd deeplearning4j
if [ "$SCALAV" == "" ]; then
if [ "$CHIP" == "cpu" ]; then
checkexit bash buildmultiplescalaversions.sh clean install -Dmaven.javadoc.skip=true -pl '!:deeplearning4j-cuda-8.0' $DL4J_OPTIONS $MVN_OPTS
else
checkexit bash buildmultiplescalaversions.sh clean install -Dmaven.javadoc.skip=true $DL4J_OPTIONS $MVN_OPTS
fi
else
if [ "$CHIP" == "cpu" ]; then
checkexit mvn clean install -Dmaven.javadoc.skip=true -Dscala.binary.version="$SCALAV" -Dscala.version="$SCALA" -pl '!:deeplearning4j-cuda-8.0' $DL4J_OPTIONS $MVN_OPTS
else
checkexit mvn clean install -Dmaven.javadoc.skip=true -Dscala.binary.version="$SCALAV" -Dscala.version="$SCALA" $DL4J_OPTIONS $MVN_OPTS
fi
fi
popd
popd