forked from scanner-research/scanner
-
Notifications
You must be signed in to change notification settings - Fork 0
/
deps.sh
903 lines (834 loc) · 29.4 KB
/
deps.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
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
#!/bin/bash
if [[ "$OSTYPE" == "linux-gnu" ]]; then
cores=$(nproc)
# ...
elif [[ "$OSTYPE" == "darwin"* ]]; then
cores=$(sysctl -n hw.ncpu)
# Mac OSX
else
# Unknown.
echo "Unknown OSTYPE: $OSTYPE. Exiting."
exit 1
fi
LOCAL_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
BUILD_DIR=$LOCAL_DIR/thirdparty/build
DEFAULT_INSTALL_DIR=$LOCAL_DIR/thirdparty/install
FILES_DIR=$LOCAL_DIR/thirdparty/resources
PYTHON_VERSION=$(python3 -c 'import sys; print(".".join(map(str, sys.version_info[:2])))')
POSITIONAL=()
# Required, ask if installed
INSTALL_OPENCV=true
INSTALL_PROTOBUF=true
INSTALL_GRPC=true
# Required, and assume not installed
INSTALL_GOOGLETEST=true
INSTALL_TINYTOML=true
INSTALL_STOREHOUSE=true
INSTALL_PYBIND=true
# Optional, ask if needed
NO_FFMPEG=false
INSTALL_FFMPEG=true
NO_OPENPOSE=false
INSTALL_OPENPOSE=true
NO_HALIDE=false
INSTALL_HALIDE=true
NO_CAFFE=false
INSTALL_CAFFE=true
NO_HWANG=false
INSTALL_HWANG=true
# Optional, and assume not installed
NO_LIBPQXX=false
INSTALL_LIBPQXX=true
USE_GPU=false
NO_USE_GPU=false
INSTALL_PREFIX=$DEFAULT_INSTALL_DIR
INSTALL_ALL=false
INSTALL_NONE=false
while [[ $# -gt 0 ]]
do
key="$1"
case $key in
-c|--cores)
cores="$2"
shift # past arg
shift # past value
;;
-g|--use-gpu)
USE_GPU=true
shift # past arg
;;
-ng|--no-use-gpu)
NO_USE_GPU=true
shift # past arg
;;
-p|--prefix)
INSTALL_PREFIX="$2"
shift # past arg
shift # past value
;;
-a|--install-all)
INSTALL_ALL=true
shift # past arg
;;
-n|--install-none)
INSTALL_NONE=true
shift # past arg
;;
--with-opencv)
WITH_OPENCV="$2"
shift # past arg
shift # past value
;;
--with-protobuf)
WITH_PROTOBUF="$2"
shift # past arg
shift # past value
;;
--with-grpc)
WITH_GRPC="$2"
shift # past arg
shift # past value
;;
--with-storehouse)
WITH_STOREHOUSE="$2"
shift # past arg
shift # past value
;;
--with-pybind)
WITH_PYBIND="$2"
shift # past arg
shift # past value
;;
--without-ffmpeg)
NO_FFMPEG=true
shift # past arg
;;
--with-ffmpeg)
WITH_FFMPEG="$2"
shift # past arg
shift # past value
;;
--without-caffe)
NO_CAFFE=true
shift # past arg
;;
--with-caffe)
WITH_CAFFE="$2"
shift # past arg
shift # past value
;;
--without-halide)
NO_HALIDE=true
shift # past arg
;;
--with-halide)
WITH_HALIDE="$2"
shift # past arg
shift # past value
;;
--without-openpose)
NO_OPENPOSE=true
shift # past arg
;;
--with-openpose)
WITH_OPENPOSE="$2"
shift # past arg
shift # past value
;;
--without-libpqxx)
NO_LIBPQXX=true
shift # past arg
;;
--with-libpqxx)
WITH_LIBPQXX="$2"
shift # past arg
shift # past value
;;
--without-hwang)
NO_HWANG=true
shift # past arg
;;
--with-hwang)
WITH_HWANG="$2"
shift # past arg
shift # past value
;;
*) # unknown option
POSITIONAL+=("$1") # save it in an array for later
shift # past argument
;;
esac
done
echo "--------------------------------------------------------------"
echo "| Scanner Dependency Installation Script |"
echo "--------------------------------------------------------------"
echo "The script will ask if required dependencies are installed and"
echo "then install missing dependencies to "
echo "$INSTALL_PREFIX"
echo "(customized by specifying (--prefix <dir>)."
set -- "${POSITIONAL[@]}" # restore positional parameters
if command -v conda list >/dev/null 2>&1; then
# Anaconda is installed, so add lib to prefix path for OpenCV to find
# PythonLib
echo "Detected Anaconda, adding lib path to OpenCV and Caffe build"
py_path=$(dirname $(which python))/../lib
PY_EXTRA_CMDS="$py_path"
else
PY_EXTRA_CMDS=""
fi
# Check if we have GPUs by looking for nvidia-smi
if command -v nvidia-smi >/dev/null 2>&1; then
HAVE_GPU=true
else
HAVE_GPU=false
fi
# Force building with GPU when specified
if [[ $USE_GPU == true ]]; then
HAVE_GPU=true
fi
# Force NOT building with GPU when specified, overriding other commands
if [[ $NO_USE_GPU == true ]]; then
HAVE_GPU=false
fi
echo ""
echo "Configuration:"
echo "--------------------------------------------------------------"
echo "Detected Python version: $PYTHON_VERSION"
echo "GPUs available: $HAVE_GPU"
echo ""
# Directories for installed dependencies
FFMPEG_DIR=$INSTALL_PREFIX
OPENCV_DIR=$INSTALL_PREFIX
PROTOBUF_DIR=$INSTALL_PREFIX
GRPC_DIR=$INSTALL_PREFIX
CAFFE_DIR=$INSTALL_PREFIX
HALIDE_DIR=$INSTALL_PREFIX
PYBIND_DIR=$INSTALL_PREFIX
HWANG_DIR=$INSTALL_PREFIX
STOREHOUSE_DIR=$INSTALL_PREFIX
TINYTOML_DIR=$INSTALL_PREFIX
OPENPOSE_DIR=$INSTALL_PREFIX
LIBPQXX_DIR=$INSTALL_PREFIX
if [[ ! -z ${WITH_FFMPEG+x} ]]; then
INSTALL_FFMPEG=false
FFMPEG_DIR=$WITH_FFMPEG
fi
if [[ ! -z ${WITH_OPENCV+x} ]]; then
INSTALL_OPENCV=false
OPENCV_DIR=$WITH_OPENCV
fi
if [[ ! -z ${WITH_PROTOBUF+x} ]]; then
INSTALL_PROTOBUF=false
PROTOBUF_DIR=$WITH_PROTOBUF
fi
if [[ ! -z ${WITH_GRPC+x} ]]; then
INSTALL_GRPC=false
GRPC_DIR=$WITH_GRPC
fi
if [[ ! -z ${WITH_CAFFE+x} ]]; then
INSTALL_CAFFE=false
CAFFE_DIR=$WITH_CAFFE
fi
if [[ ! -z ${WITH_HALIDE+x} ]]; then
INSTALL_HALIDE=false
HALIDE_DIR=$WITH_HALIDE
fi
if [[ ! -z ${WITH_PYBIND+x} ]]; then
INSTALL_PYBIND=false
PYBIND_DIR=$WITH_PYBIND
fi
if [[ ! -z ${WITH_HWANG+x} ]]; then
INSTALL_HWANG=false
HWANG_DIR=$WITH_HWANG
fi
if [[ ! -z ${WITH_STOREHOUSE+x} ]]; then
INSTALL_STOREHOUSE=false
STOREHOUSE_DIR=$WITH_STOREHOUSE
fi
if [[ ! -z ${WITH_OPENPOSE+x} ]]; then
INSTALL_OPENPOSE=false
OPENPOSE_DIR=$WITH_OPENPOSE
fi
if [[ ! -z ${WITH_LIBPQXX+x} ]]; then
INSTALL_LIBPQXX=false
LIBPQXX_DIR=$WITH_LIBPQXX
fi
export C_INCLUDE_PATH=$INSTALL_PREFIX/include:$C_INCLUDE_PATH
export LD_LIBRARY_PATH=$INSTALL_PREFIX/lib:$LD_LIBRARY_PATH
export PATH=$INSTALL_PREFIX/bin:$PATH
export PKG_CONFIG_PATH=$INSTALL_PREFIX/lib/pkgconfig:$PGK_CONFIG_PATH
mkdir -p $BUILD_DIR
mkdir -p $INSTALL_PREFIX
if [[ $INSTALL_NONE == true ]]; then
INSTALL_FFMPEG=false
INSTALL_OPENCV=false
INSTALL_PROTOBUF=false
INSTALL_GRPC=false
INSTALL_CAFFE=false
INSTALL_HALIDE=false
INSTALL_OPENPOSE=false
INSTALL_GOOGLETEST=false
INSTALL_HWANG=false
INSTALL_TINYTOML=false
INSTALL_STOREHOUSE=false
INSTALL_PYBIND=false
INSTALL_LIBPQXX=false
elif [[ $INSTALL_ALL == false ]]; then
# Ask about each library
echo "Required dependencies: "
if [[ -z ${WITH_OPENCV+x} ]]; then
echo -n "Do you have opencv>=3.4.0 with contrib installed? [y/N]: "
read yn
if [[ $yn == y ]] || [[ $yn == Y ]]; then
INSTALL_OPENCV=false
echo -n "Where is your opencv install? [/usr/local]: "
read install_location
if [[ $install_location == "" ]]; then
OPENCV_DIR=/usr/local
else
OPENCV_DIR=$install_location
fi
else
INSTALL_OPENCV=true
fi
fi
if [[ -z ${WITH_PROTOBUF+x} ]]; then
echo -n "Do you have protobuf>=3.6.1 installed? [y/N]: "
read yn
if [[ $yn == y ]] || [[ $yn == Y ]]; then
INSTALL_PROTOBUF=false
echo -n "Where is your protobuf install? [/usr/local]: "
read install_location
if [[ $install_location == "" ]]; then
PROTOBUF_DIR=/usr/local
else
PROTOBUF_DIR=$install_location
fi
else
INSTALL_PROTOBUF=true
fi
fi
if [[ -z ${WITH_GRPC+x} ]]; then
echo -n "Do you have grpc==1.16.0 installed? [y/N]: "
read yn
if [[ $yn == y ]] || [[ $yn == Y ]]; then
INSTALL_GRPC=false
echo -n "Where is your grpc install? [/usr/local]: "
read install_location
if [[ $install_location == "" ]]; then
GRPC_DIR=/usr/local
else
GRPC_DIR=$install_location
fi
else
INSTALL_GRPC=true
fi
fi
echo "Optional dependencies: "
if [[ -z ${WITH_FFMPEG+x} ]] && [[ ${NO_FFMPEG+x} != true ]]; then
echo -n "Do you need support for processing video files (e.g. mp4)? [Y/n]: "
read yn
if [[ $yn != n ]] && [[ $yn != N ]]; then
echo -n "Do you have ffmpeg>=3.3.1 installed? [y/N]: "
read yn
if [[ $yn == y ]] || [[ $yn == Y ]]; then
INSTALL_FFMPEG=false
echo -n "Where is your ffmpeg install? [/usr/local]: "
read install_location
if [[ $install_location == "" ]]; then
FFMPEG_DIR=/usr/local
else
FFMPEG_DIR=$install_location
fi
else
INSTALL_FFMPEG=true
echo "ffmpeg 3.3.1 will be installed at ${FFMPEG_DIR}."
fi
else
INSTALL_FFMPEG=false
NO_FFMPEG=true
fi
fi
if [[ -z ${WITH_HALIDE+x} ]] && [[ ${NO_HALIDE+x} != true ]]; then
echo -n "Do you need support for halide pipelines? [y/N]: "
read yn
if [[ $yn == y ]] || [[ $yn == Y ]]; then
echo -n "Do you have halide (release_2018_02_15) installed? [y/N]: "
read yn
if [[ $yn == y ]] || [[ $yn == Y ]]; then
INSTALL_HALIDE=false
echo -n "Where is your halide install? [/usr/local]: "
read install_location
if [[ $install_location == "" ]]; then
HALIDE_DIR=/usr/local
else
HALIDE_DIR=$install_location
fi
else
INSTALL_HALIDE=true
echo "halide will be installed at ${HALIDE_DIR}."
fi
else
INSTALL_HALIDE=false
NO_HALIDE=true
fi
fi
if [[ -z ${WITH_OPENPOSE+x} ]] && [[ ${NO_OPENPOSE+x} != true ]]; then
echo -n "Do you need support for Pose Detection (openpose)? [Y/n]: "
read yn
if [[ $yn != n ]] && [[ $yn != N ]]; then
echo -n "Do you have OpenPose (v1.3.0) installed? [y/N]: "
read yn
if [[ $yn == y ]] || [[ $yn == Y ]]; then
INSTALL_OPENPOSE=false
echo -n "Where is your OpenPose install? [/usr/local]: "
read install_location
if [[ $install_location == "" ]]; then
OPENPOSE_DIR=/usr/local
else
OPENPOSE_DIR=$install_location
fi
else
INSTALL_OPENPOSE=true
fi
else
INSTALL_OPENPOSE=false
NO_OPENPOSE=true
fi
fi
if [[ -z ${WITH_CAFFE+x} ]] && [[ ${NO_CAFFE+x} != true ]]; then
echo -n "Do you need support for Caffe operations? [Y/n]: "
read yn
if [[ $yn != n ]] && [[ $yn != N ]]; then
echo -n "Do you have caffe>=rc5 or intel-caffe>=1.0.6 installed? [y/N]: "
read yn
if [[ $yn == y ]] || [[ $yn == Y ]]; then
INSTALL_CAFFE=false
echo -n "Where is your caffe install? [/usr/local]: "
read install_location
if [[ $install_location == "" ]]; then
CAFFE_DIR=/usr/local
else
CAFFE_DIR=$install_location
fi
else
INSTALL_CAFFE=true
if [[ $HAVE_GPU == true ]]; then
echo -n "Do you plan to use GPUs for CNN evaluation? [Y/n]: "
read yn
if [[ $yn == n ]] || [[ $yn == N ]]; then
USE_GPU=false
else
USE_GPU=true
fi
else
USE_GPU=false
fi
fi
else
INSTALL_CAFFE=false
NO_CAFFE=true
fi
fi
if [[ -z ${WITH_LIBPQXX+x} ]] && [[ ${NO_LIBPQXX+x} != true ]]; then
echo -n "Do you need support for SQL input/output? [y/N]: "
read yn
if [[ $yn == y ]] || [[ $yn == Y ]]; then
INSTALL_LIBPQXX=true
echo "libpqxx will be installed at ${LIBPQXX_DIR}."
else
INSTALL_LIBPQXX=false
NO_LIBPQXX=true
fi
fi
if [[ ${NO_HWANG+x} == true ]]; then
INSTALL_HWANG=false
NO_HWANG=true
fi
fi
if [[ $INSTALL_OPENCV == true ]] && [[ ! -f $BUILD_DIR/opencv.done ]]; then
# OpenCV 3.4.0 + OpenCV contrib
echo "Installing OpenCV 3.4.0..."
# Determine command string to use
if [[ "$OSTYPE" == "linux-gnu" ]]; then
# Linux
CMDS=""
# ...
elif [[ "$OSTYPE" == "darwin"* ]]; then
# Mac OSX
CMDS="-DWITH_CUDA=OFF"
fi
cd $BUILD_DIR
rm -rf opencv opencv_contrib ceres-solver
git clone -b 3.4.1 https://github.com/opencv/opencv --depth 1 && \
git clone -b 3.4.1 https://github.com/opencv/opencv_contrib \
--depth 1 && \
git clone -b 1.14.0 https://github.com/ceres-solver/ceres-solver \
--depth 1 && \
cd ceres-solver && mkdir -p build_cmake && cd build_cmake && \
cmake .. -DCMAKE_INSTALL_PREFIX=$INSTALL_PREFIX && \
make install -j$cores && \
mkdir -p $BUILD_DIR/opencv/build && cd $BUILD_DIR/opencv/build && \
cmake -D CMAKE_BUILD_TYPE=Release \
-D CMAKE_INSTALL_PREFIX=$INSTALL_PREFIX \
-D BUILD_TESTS=OFF -D BUILD_PERF_TESTS=OFF -D ENABLE_FAST_MATH=1 \
-D CUDA_FAST_MATH=1 -D WITH_CUBLAS=1 -D WITH_NVCUVID=1 \
-D BUILD_opencv_rgbd=OFF \
-D BUILD_opencv_cnn_3dobj=OFF \
-D OPENCV_EXTRA_MODULES_PATH=$BUILD_DIR/opencv_contrib/modules \
$(echo $CMDS) -DCMAKE_PREFIX_PATH=$(echo $PY_EXTRA_CMDS) \
.. && \
make install -j$cores && touch $BUILD_DIR/opencv.done \
|| { echo 'Installing OpenCV failed!' ; exit 1; }
echo "Done installing OpenCV 3.4.0"
fi
if [[ $INSTALL_PROTOBUF == true ]] && [[ ! -f $BUILD_DIR/protobuf.done ]] ; then
# protobuf 3.6.1
echo "Installing protobuf 3.6.1..."
cd $BUILD_DIR
rm -fr protobuf
git clone -b v3.6.1 https://github.com/google/protobuf.git --depth 1 && \
cd protobuf && bash ./autogen.sh && \
./configure --prefix=$INSTALL_PREFIX && make -j$cores && \
make install && touch $BUILD_DIR/protobuf.done \
|| { echo 'Installing protobuf failed!' ; exit 1; }
echo "Done installing protobuf 3.6.1"
fi
if [[ $INSTALL_GRPC == true ]] && [[ ! -f $BUILD_DIR/grpc.done ]] ; then
# gRPC 1.16.0
echo "Installing gRPC 1.16.0..."
cd $BUILD_DIR
rm -fr grpc
git clone -b v1.16.0 https://github.com/grpc/grpc && \
cd grpc && git submodule update --init --recursive && \
CPPFLAGS=-I$INSTALL_PREFIX/include LDFLAGS=-L$INSTALL_PREFIX/lib make -j$cores && \
CPPFLAGS=-I$INSTALL_PREFIX/include LDFLAGS=-L$INSTALL_PREFIX/lib make install prefix=$INSTALL_PREFIX && \
touch $BUILD_DIR/grpc.done \
|| { echo 'Installing gRPC failed!' ; exit 1; }
if [[ "$OSTYPE" == "linux-gnu" ]]; then
# Linux
ldconfig -n $INSTALL_PREFIX/lib
elif [[ "$OSTYPE" == "darwin"* ]]; then
# OS X
install_name_tool -id "@rpath/libgrpc++_unsecure.dylib" \
$INSTALL_PREFIX/lib/libgrpc++_unsecure.dylib
install_name_tool -id "@rpath/libgrpc.dylib" \
$INSTALL_PREFIX/lib/libgrpc.dylib
install_name_tool -id "@rpath/libgpr.dylib" \
$INSTALL_PREFIX/lib/libgpr.dylib
install_name_tool -change libgpr.dylib @rpath/libgpr.dylib \
$INSTALL_PREFIX/lib/libgrpc++_unsecure.dylib
install_name_tool -change libgrpc_unsecure.dylib @rpath/libgrpc_unsecure.dylib \
$INSTALL_PREFIX/lib/libgrpc++_unsecure.dylib
fi
echo "Done installing gRPC 1.16.0"
fi
if [[ $INSTALL_FFMPEG == true ]] && [[ ! -f $BUILD_DIR/ffmpeg.done ]] ; then
echo "Installing ffmpeg 3.3.1..."
# Determine command string to use
if [[ "$OSTYPE" == "linux-gnu" ]]; then
# Linux
CMDS="--extra-version=0ubuntu0.16.04.1
--toolchain=hardened
--cc=cc --cxx=g++"
# ...
elif [[ "$OSTYPE" == "darwin"* ]]; then
# Mac OSX
CMDS=""
fi
# FFMPEG
cd $BUILD_DIR
rm -fr ffmpeg
git clone -b n3.3.1 https://git.ffmpeg.org/ffmpeg.git && cd ffmpeg && \
./configure --prefix=$INSTALL_PREFIX \
--enable-shared --disable-stripping \
--disable-decoder=libschroedinger \
--enable-avresample \
--enable-libx264 \
--enable-nonfree \
--enable-gpl \
--enable-gnutls \
$(echo $CMDS) && \
make -j${cores} && make install && touch $BUILD_DIR/ffmpeg.done \
|| { echo 'Installing ffmpeg failed!' ; exit 1; }
echo "Done installing ffmpeg 3.3.1"
fi
if [[ $INSTALL_PYBIND == true ]] && [[ ! -f $BUILD_DIR/pybind.done ]] ; then
echo "Installing pybind..."
cd $BUILD_DIR
rm -fr pybind11
git clone -b v2.2.2 https://github.com/pybind/pybind11 --depth 1 && \
cd pybind11 && \
mkdir build && cd build && \
cmake .. -DCMAKE_INSTALL_PREFIX=$INSTALL_PREFIX -DPYBIND11_TEST=Off -DCMAKE_BUILD_TYPE=RelWithDebInfo && \
make install -j${cores} && cd ../../ && \
touch $BUILD_DIR/pybind.done \
|| { echo 'Installing pybind failed!' ; exit 1; }
echo "Done installing pybind"
fi
if [[ $INSTALL_STOREHOUSE == true ]] && [[ ! -f $BUILD_DIR/storehouse.done ]] ; then
echo "Installing storehouse..."
cd $BUILD_DIR
rm -fr storehouse
git clone https://github.com/scanner-research/storehouse && \
cd storehouse && \
git checkout v0.6.3 && \
cd thirdparty && mkdir build && cd build && \
cmake .. -DCMAKE_INSTALL_PREFIX=$INSTALL_PREFIX -DCMAKE_BUILD_TYPE=RelWithDebInfo && \
make -j${cores} && cd ../../ && \
mkdir build && cd build && \
cmake .. -DCMAKE_INSTALL_PREFIX=$INSTALL_PREFIX -DCMAKE_BUILD_TYPE=RelWithDebInfo && \
make install -j${cores} && cd .. && \
CPATH=$INSTALL_PREFIX/include LD_LIBRARY_PATH=$INSTALL_PREFIX/lib ./build.sh && \
touch $BUILD_DIR/storehouse.done \
|| { echo 'Installing storehouse failed!' ; exit 1; }
echo "Done installing storehouse"
fi
if [[ $INSTALL_GOOGLETEST == true ]] && [[ ! -f $BUILD_DIR/googletest.done ]]; then
echo "Installing googletest..."
cd $BUILD_DIR
rm -fr googletest
git clone https://github.com/google/googletest && \
cd googletest && git checkout release-1.8.1 && \
mkdir build && cd build && \
cmake .. -DCMAKE_INSTALL_PREFIX=$INSTALL_PREFIX && \
make -j${cores} && make install && \
touch $BUILD_DIR/googletest.done \
|| { echo 'Installing googletest failed!' ; exit 1; }
echo "Done installing googletest"
fi
if [[ $INSTALL_HWANG == true ]] && [[ ! -f $BUILD_DIR/hwang.done ]] ; then
echo "Installing hwang..."
cd $BUILD_DIR
rm -fr hwang
git clone https://github.com/scanner-research/hwang && \
cd hwang && \
git checkout v0.3.7 && \
bash ./deps.sh -a \
--with-ffmpeg $INSTALL_PREFIX \
--with-protobuf $INSTALL_PREFIX \
--cores ${cores} && \
mkdir -p build && cd build && \
cmake .. -DCMAKE_BUILD_TYPE=RelWithDebInfo -DCMAKE_INSTALL_PREFIX=$INSTALL_PREFIX -DBUILD_CUDA=$USE_GPU && \
make install -j${cores} && cd .. && ./build.sh && \
touch $BUILD_DIR/hwang.done \
|| { echo 'Installing hwang failed!' ; exit 1; }
echo "Done installing hwang"
fi
if [[ $INSTALL_TINYTOML == true ]] && [[ ! -f $BUILD_DIR/tinytoml.done ]]; then
echo "Installing tinytoml..."
cd $BUILD_DIR
rm -fr tinytoml
git clone https://github.com/mayah/tinytoml.git && \
cd tinytoml && git checkout 3559856002eee57693349b8a2d8a0cf6250d269c && \
cp -r include/* $INSTALL_PREFIX/include && \
touch $BUILD_DIR/tinytoml.done \
|| { echo 'Installing tinytoml failed!' ; exit 1; }
echo "Done installing tinytoml"
fi
if [[ $INSTALL_HALIDE == true ]] && [[ ! -f $BUILD_DIR/halide.done ]] ; then
# Halide
echo "Installing Halide..."
cd $BUILD_DIR
rm -fr Halide
mkdir Halide
cd Halide
if [[ "$OSTYPE" == "linux-gnu" ]]; then
# If CLANG is not set, we should set it to clang or clang-5.0
if [ -z ${CLANG+x} ]; then
if command -v clang >/dev/null 2>&1 &&
[[ $(clang++ -v 2>&1 |
grep version |
sed 's/.*version \([0-9]*.[0-9]*.[0-9]*\) .*/\1/g' |
perl -pe '($_)=/([0-9]+([.][0-9]+)+)/') > '4.0.0' ]]; then
export CLANG=clang
elif command -v clang-5.0 >/dev/null 2>&1; then
export CLANG=clang-5.0
fi
echo $CLANG
fi
# If LLVM_CONFIG is not set, we should set it to llvm-config or
# llvm-config-5.0
if [ -z ${LLVM_CONFIG+x} ]; then
if command -v llvm-config >/dev/null 2>&1 &&
[[ $(llvm-config --version) > '4.0.0' ]]; then
export LLVM_CONFIG=llvm-config
elif command -v llvm-config-5.0 >/dev/null 2>&1; then
export LLVM_CONFIG=llvm-config-5.0
fi
fi
git clone -b release_2018_02_15 https://github.com/halide/Halide --depth 1 && \
cd Halide && \
make distrib -j$cores && \
cp -r distrib/* $INSTALL_PREFIX && \
touch $BUILD_DIR/halide.done \
|| { echo 'Installing Halide failed!' ; exit 1; }
elif [[ "$OSTYPE" == "darwin"* ]]; then
TAR_NAME=halide-mac-64-trunk-46d8e9e0cdae456489f1eddfd6d829956fc3c843.tgz
wget --retry-on-http-error=403 https://github.com/halide/Halide/releases/download/release_2018_02_15/$TAR_NAME && \
wget --retry-on-http-error=403 https://raw.githubusercontent.com/halide/Halide/release_2018_02_15/src/Generator.h && \
tar -zxf $TAR_NAME && \
cp Generator.h halide/include && \
mkdir -p $INSTALL_PREFIX/lib && \
find ./halide -type f -exec chmod 644 {} + && \
find ./halide -type d -exec chmod 755 {} + && \
find ./halide/bin -type f -exec chmod 755 {} + && \
cp -r halide/bin/* $INSTALL_PREFIX/lib && \
rm -r halide/bin && \
cp -r halide/* $INSTALL_PREFIX && \
install_name_tool -id "@rpath/libHalide.dylib" $INSTALL_PREFIX/lib/libHalide.dylib
touch $BUILD_DIR/halide.done \
|| { echo 'Installing Halide failed!' ; exit 1; }
fi
echo "Done installing Halide"
fi
if [[ $INSTALL_CAFFE == true ]] && [[ $USE_GPU == false ]] && \
[[ "$OSTYPE" == "linux-gnu" ]] && [[ ! -f $BUILD_DIR/caffe.done ]]; then
# Intel Caffe 1.0.6
cd $BUILD_DIR
rm -fr caffe
# Use more recent mkldnn commit to fix gcc bug
git clone -b 1.0.6 https://github.com/intel/caffe --depth 1 && \
cd caffe && \
cp $FILES_DIR/caffe/Makefile.config Makefile.config && \
rm mkldnn.commit && \
echo "2604f435da7bb9f1896ae37200d91734adfdba9c" > mkldnn.commit && \
mkdir build && cd build && \
cmake -DCMAKE_INSTALL_PREFIX=$INSTALL_PREFIX \
-DCMAKE_PREFIX_PATH="$INSTALL_PREFIX;$PY_EXTRA_CMDS" \
-DCPU_ONLY=ON \
-DOpenCV_DIR=$OPENCV_DIR \
-DBUILD_python=OFF \
-Dpython_version=3 \
-DBLAS=mkl \
.. && \
make -j${cores} && \
make install && \
cd .. && \
cp -r external/mkl/mklml_lnx_2018.0.20170908/* $INSTALL_PREFIX && \
cp -r external/mkldnn/install/* $INSTALL_PREFIX && \
touch $BUILD_DIR/caffe.done \
|| { echo 'Installing caffe failed!' ; exit 1; }
fi
#if [[ $INSTALL_CAFFE == true ]] &&
if [[ $INSTALL_CAFFE == true ]] && \
([[ $USE_GPU == true ]] ||
[[ "$OSTYPE" == "darwin"* ]]) && \
[[ ! -f $BUILD_DIR/caffe.done ]]; then
cd $BUILD_DIR
# Intel MKL
if [[ "$OSTYPE" == "linux-gnu" ]]; then
rm -fr mkl
mkdir mkl && \
cd mkl && \
wget http://registrationcenter-download.intel.com/akdlm/irc_nas/tec/12414/l_mkl_2018.1.163.tgz && \
tar -zxf l_mkl_2018.1.163.tgz && \
cp $FILES_DIR/mkl/silent.cfg silent.cfg && \
echo "PSET_INSTALL_DIR=$INSTALL_PREFIX/intel" >> silent.cfg && \
cd l_mkl_2018.1.163 && \
bash install.sh --cli-mode --silent ../silent.cfg
fi
if [[ $USE_GPU == true ]]; then
CPU_ONLY=OFF
else
CPU_ONLY=ON
fi
cd $BUILD_DIR
# Caffe rc5
rm -fr caffe
git clone https://github.com/BVLC/caffe && \
cd caffe &&
git checkout 18b09e807a6e146750d84e89a961ba8e678830b4 &&
cp $FILES_DIR/caffe/Makefile.config Makefile.config && \
mkdir build && cd build && \
cmake -DCMAKE_INSTALL_PREFIX=$INSTALL_PREFIX \
-DCMAKE_PREFIX_PATH=$INSTALL_PREFIX \
-DINTEL_ROOT=$INSTALL_PREFIX/intel \
-DCPU_ONLY=$CPU_ONLY \
-DBLAS=mkl \
-DBUILD_python=OFF \
-Dpython_version=3 \
-DCUDA_ARCH_NAME="Manual" \
-DCUDA_ARCH_BIN="30 35 50 60 61" \
-DCUDA_ARCH_PTX="30 35 50 60 61" \
-DOpenCV_DIR=$INSTALL_PREFIX \
-DCMAKE_CXX_FLAGS="-std=c++11" \
.. && \
make -j${cores} && \
make install && \
touch $BUILD_DIR/caffe.done \
|| { echo 'Installing caffe failed!' ; exit 1; }
fi
if [[ $INSTALL_OPENPOSE == true ]] && [[ ! -f $BUILD_DIR/openpose.done ]] && \
! [[ "$OSTYPE" == "darwin"* ]]; then
EXTRA_FLAGS=""
if [[ $HAVE_GPU == false ]]; then
EXTRA_FLAGS="-DGPU_MODE=CPU_ONLY"
fi
cd $BUILD_DIR
rm -rf openpose
git clone -b v1.3.0 https://github.com/CMU-Perceptual-Computing-Lab/openpose --depth 1 && \
cd openpose && mkdir build && cd build && \
cmake -D CMAKE_INSTALL_PREFIX=$INSTALL_PREFIX \
-D CMAKE_PREFIX_PATH=$INSTALL_PREFIX \
-D OpenCV_DIR=$INSTALL_PREFIX \
-D BUILD_CAFFE=OFF \
-D Caffe_INCLUDE_DIRS=$CAFFE_DIR/include \
-D Caffe_LIBS=$CAFFE_DIR/lib/libcaffe.so \
-D BUILD_EXAMPLES=Off \
-D BUILD_DOCS=Off \
-D DOWNLOAD_COCO_MODEL=Off \
-D DOWNLOAD_HAND_MODEL=Off \
-D DOWNLOAD_FACE_MODEL=Off \
-DCUDA_ARCH="Manual" \
-DCUDA_ARCH_BIN="30 35 50 60 61" \
-DCUDA_ARCH_PTX="30 35 50 60 61" \
${EXTRA_FLAGS} \
.. && \
make install -j${cores} && \
touch $BUILD_DIR/openpose.done \
|| { echo 'Installing OpenPose failed!'; exit 1; }
fi
if [[ $INSTALL_LIBPQXX == true ]] && [[ ! -f $BUILD_DIR/libpqxx.done ]]; then
cd $BUILD_DIR
rm -rf libpqxx
git clone -b 6.2.2 https://github.com/jtv/libpqxx --depth 1 && \
cd libpqxx && \
CXXFLAGS="-fPIC" ./configure --prefix=$INSTALL_PREFIX --disable-documentation && \
make install -j${cores} && \
touch $BUILD_DIR/libpqxx.done \
|| { echo 'Installing libpqxx failed!'; exit 1; }
fi
DEP_FILE=$LOCAL_DIR/dependencies.txt
rm -f $DEP_FILE
echo "HAVE_GPU=$HAVE_GPU" >> $DEP_FILE
echo "CAFFE_GPU=$USE_GPU" >> $DEP_FILE
echo "OpenCV_DIR=$OPENCV_DIR" >> $DEP_FILE
echo "PROTOBUF_DIR=$PROTOBUF_DIR" >> $DEP_FILE
echo "GRPC_DIR=$GRPC_DIR" >> $DEP_FILE
echo "TinyToml_DIR=$TINYTOML_DIR" >> $DEP_FILE
echo "STOREHOUSE_DIR=$STOREHOUSE_DIR" >> $DEP_FILE
echo "PYBIND11_DIR=$PYBIND_DIR" >> $DEP_FILE
echo "NO_FFMPEG=$NO_FFMPEG" >> $DEP_FILE
echo "FFMPEG_DIR=$FFMPEG_DIR" >> $DEP_FILE
echo "NO_OPENPOSE=$NO_OPENPOSE" >> $DEP_FILE
echo "NO_CAFFE=$NO_CAFFE" >> $DEP_FILE
echo "Caffe_DIR=$CAFFE_DIR" >> $DEP_FILE
echo "NO_HALIDE=$NO_HALIDE" >> $DEP_FILE
echo "Halide_DIR=$HALIDE_DIR" >> $DEP_FILE
echo "NO_LIBPQXX=$NO_LIBPQXX" >> $DEP_FILE
echo "LIBPQXX_DIR=$LIBPQXX_DIR" >> $DEP_FILE
echo "Hwang_DIR=$HWANG_DIR" >> $DEP_FILE
echo "NO_HWANG=$NO_HWANG" >> $DEP_FILE
echo "Done installing dependencies!"
echo -n "Add $INSTALL_PREFIX/lib to your LD_LIBRARY_PATH, "
echo -n "add $INSTALL_PREFIX/bin to your PATH, and "
echo -n "add $INSTALL_PREFIX/lib/pkgconfig to your PKG_CONFIG_PATH so the installed "
echo -n "dependencies can be found! "
echo "e.g. export LD_LIBRARY_PATH=$INSTALL_PREFIX/lib:\$LD_LIBRARY_PATH"
if [[ $INSTALL_OPENCV == true ]]; then
echo "Add $INSTALL_PREFIX/lib/python$PYTHON_VERSION/dist-packages to your PYTHONPATH to use OpenCV from Python"
fi
if [[ $INSTALL_CAFFE_CPU == true ]] || [[ $INSTALL_CAFFE_GPU == true ]]; then
echo "Add $INSTALL_PREFIX/python to your PYTHONPATH to use Caffe from Python"
fi