This repository has been archived by the owner on Jul 1, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 27
/
install-script.sh
executable file
·97 lines (78 loc) · 2.52 KB
/
install-script.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
#!/usr/bin/env bash
if [ ! -d darknet ]; then
git clone https://github.com/AlexeyAB/darknet --depth=1;
if [ $? -ne 0 ]; then
echo "Could not clone darknet repo";
exit 1;
fi
fi
# dive in the darknet folder and make
cd darknet
# look for exported variables for GPU and CUDNN
GPU="${DARKNET_BUILD_WITH_GPU:-0}";
CUDNN="${DARKNET_BUILD_WITH_CUDNN:-0}";
OPENCV="${DARKNET_BUILD_WITH_OPENCV:-0}";
OPENMP="${DARKNET_BUILD_WITH_OPENMP:-0}";
CUDNN_HALF="${DARKNET_BUILD_WITH_CUDNN_HALF:-0}";
AVX="${DARKNET_BUILD_WITH_AVX:-0}";
case "$GPU" in
1|0);;
*) echo "Interpreting DARKNET_BUILD_WITH_GPU=$GPU as 0"; GPU=0;;
esac
case "$CUDNN" in
1|0);;
*) echo "Interpreting DARKNET_BUILD_WITH_CUDNN=$CUDNN as 0"; CUDNN=0;;
esac
case "$CUDNN_HALF" in
1|0);;
*) echo "Interpreting DARKNET_BUILD_WITH_CUDNN_HALF=$CUDNN_HALF as 0"; CUDNN_HALF=0;;
esac
case "$OPENCV" in
1|0);;
*) echo "Interpreting DARKNET_BUILD_WITH_OPENCV=$OPENCV as 0"; OPENCV=0;;
esac
case "$OPENMP" in
1|0);;
*) echo "Interpreting DARKNET_BUILD_WITH_OPENMP=$OPENMP as 0"; OPENMP=0;;
esac
case "$AVX" in
1|0);;
*) echo "Interpreting DARKNET_BUILD_WITH_AVX=$AVX as 0"; AVX=0;;
esac
sed -i -e "s/AVX=[01]/AVX=${AVX}/g" ./Makefile
sed -i -e "s/GPU=[01]/GPU=${GPU}/g" ./Makefile
sed -i -e "s/CUDNN=[01]/CUDNN=${CUDNN}/g" ./Makefile
sed -i -e "s/OPENCV=[01]/OPENCV=${OPENCV}/g" ./Makefile
sed -i -e "s/OPENMP=[01]/OPENMP=${OPENMP}/g" ./Makefile
sed -i -e "s/CUDNN_HALF=[01]/CUDNN_HALF=${CUDNN_HALF}/g" ./Makefile
sed -i -e "s/LIBSO=[01]/LIBSO=1/g" ./Makefile
DEFAULT_ARCH=" -gencode arch=compute_35,code=sm_35 \
-gencode arch=compute_50,code=[sm_50,compute_50] \
-gencode arch=compute_52,code=[sm_52,compute_52] \
-gencode arch=compute_61,code=[sm_61,compute_61]"
# Remove trailing gencode lines
sed -i -e "/^\s*-gencode/d" ./Makefile
if [ ! -z "${DARKNET_BUILD_WITH_ARCH:-""}" ]; then
echo ""
echo "Note: Passing custom ARCH for Darknet build"
echo""
# Update the ARCH to be what was specified by the option
sed -i -e "s/^ARCH=.*$/ARCH=${DARKNET_BUILD_WITH_ARCH}/g" ./Makefile
else
sed -i -e "s/^ARCH=.*$/ARCH=${DEFAULT_ARCH}/g" ./Makefile
fi
make
if [ $? -ne 0 ]; then
echo "Could not compile darknet";
exit 2;
fi
# dive out
cd ..
if [ $GPU = 1 ]; then
export DARKNET_DEFINES="GPU"
export DARKNET_FLAGS="-L/usr/local/cuda/lib64 -lcuda -lcudart -lcublas -lcurand"
fi
if [ $CUDNN = 1 ]; then
export DARKNET_DEFINES="$DARKNET_DEFINES CUDNN"
export DARKNET_FLAGS="$DARKNET_FLAGS -l cudnn"
fi