-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbuild-cuda.sh
155 lines (139 loc) · 5.18 KB
/
build-cuda.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
#!/bin/bash
ocv_ver="4.5.2"
rdir=`pwd`
ffmpeg_version="4.4"
#Install Dependencies
sudo apt update
sudo apt -y dist-upgrade
sudo apt install -y sudo nano htop mediainfo build-essential autoconf automake cmake libtool git \
checkinstall nasm yasm libass-dev htop libfreetype6-dev libsdl2-dev p11-kit \
libva-dev libvdpau-dev libvorbis-dev libxcb1-dev libxcb-shm0-dev \
libxcb-xfixes0-dev pkg-config texinfo wget zlib1g-dev \
frei0r-plugins-dev gnutls-dev ladspa-sdk libcaca-dev libcdio-paranoia-dev \
libcodec2-dev libfontconfig1-dev libfreetype6-dev libfribidi-dev libgme-dev \
libgsm1-dev libjack-dev libmodplug-dev libmp3lame-dev libopencore-amrnb-dev \
libopencore-amrwb-dev libopenjp2-7-dev libopenmpt-dev libopus-dev \
libpulse-dev librsvg2-dev librubberband-dev librtmp-dev libshine-dev \
libsmbclient-dev libsnappy-dev libsoxr-dev libspeex-dev libssh-dev \
libtesseract-dev libtheora-dev libtwolame-dev libv4l-dev libvo-amrwbenc-dev \
libvorbis-dev libvpx-dev libwavpack-dev libwebp-dev libx264-dev libx265-dev \
libxvidcore-dev libxml2-dev libzmq3-dev libzvbi-dev liblilv-dev libdrm-dev \
libopenal-dev opencl-dev libjack-dev libbluray-dev libfdk-aac-dev openssl libssl-dev \
libunistring-dev libbluray-dev libcurl4-openssl-dev unzip libgphoto2-dev libtesseract-dev tesseract-ocr libvo-amrwbenc-dev libvpx-dev libwebp-dev libx265-dev libzmq3-dev libx264-dev frei0r-plugins-dev gcc gobjc pkg-config libpthread-stubs0-dev libpciaccess-dev make patch yasm g++ autoconf cmake automake build-essential libass-dev libfreetype6-dev libgpac-dev libsdl1.2-dev libtheora-dev libtool libva-dev libvdpau-dev libvorbis-dev libx11-dev libxext-dev libxfixes-dev texi2html zlib1g-dev libx264-dev libmp3lame-dev libfaac-dev librtmp-dev libvo-aacenc-dev libx264-dev libgtk-3-dev python-numpy python3-numpy libdc1394-22 libdc1394-22-dev libjpeg-dev libtiff5-dev libavcodec-dev libavformat-dev libswscale-dev libxine2-dev libgstreamer1.0-dev libgstreamer-plugins-base1.0-dev libv4l-dev libtbb-dev qtbase5-dev libfaac-dev libmp3lame-dev libopencore-amrnb-dev libopencore-amrwb-dev libtheora-dev libvorbis-dev libxvidcore-dev x264 v4l-utils unzip libopus-dev libsoxr-dev libleptonica-dev libspeex-dev libjpeg-dev libpng-dev libtiff-dev
#Download OpenCV, OpenCV_contrib and FFmpeg
wget https://github.com/opencv/opencv/archive/$ocv_ver.zip -O opencv-$ocv_ver.zip
wget https://github.com/opencv/opencv_contrib/archive/$ocv_ver.zip -O opencv_contrib-$ocv_ver.zip
wget https://ffmpeg.org/releases/ffmpeg-$ffmpeg_version.tar.xz
#Build and Install FFmpeg
#Install cuda video headers
git clone https://git.videolan.org/git/ffmpeg/nv-codec-headers.git
cd nv-codec-headers
make
sudo make install
cd ..
tar -xf ffmpeg-$ffmpeg_version.tar.xz
cd ffmpeg-$ffmpeg_version
sed -i 's/_30/_52/g' configure #as of FFmpeg 4.3, sm_30 and compute_30 break building using nvcc, here they're replaced with 52
#librtmp is disabled intentionally to enable built-in FFmpeg RTMP protocol which is more reliable
export PATH=/usr/local/cuda/bin${PATH:+:${PATH}}
./configure \
--disable-static \
--enable-cuda-nvcc \
--enable-cuvid \
--enable-decoder='mjpeg,png,jpg' \
--enable-demuxer=image2 \
--enable-ffnvcodec \
--enable-frei0r \
--enable-gmp \
--enable-gnutls \
--enable-gpl \
--enable-iconv \
--enable-indev=alsa \
--enable-ladspa \
--enable-libass \
--enable-libbluray \
--enable-libcaca \
--enable-libcdio \
--enable-libcodec2 \
--enable-libdrm \
--enable-libfdk-aac \
--enable-libfontconfig \
--enable-libfreetype \
--enable-libfribidi \
--enable-libgme \
--enable-libgsm \
--enable-libjack \
--enable-libmodplug \
--enable-libmp3lame \
--enable-libnpp \
--enable-libopencore-amrnb \
--enable-libopencore-amrwb \
--enable-libopenjpeg \
--enable-libopenmpt \
--enable-libopus \
--enable-libpulse \
--enable-librsvg \
--disable-librtmp \
--enable-librubberband \
--enable-libshine \
--enable-libsnappy \
--enable-libsoxr \
--enable-libspeex \
--enable-libssh \
--enable-libtheora \
--enable-libtwolame \
--enable-libv4l2 \
--enable-libvo-amrwbenc \
--enable-libvorbis \
--enable-libvpx \
--enable-libwebp \
--enable-libx264 \
--enable-libx265 \
--enable-libxml2 \
--enable-libxvid \
--enable-libzmq \
--enable-libzvbi \
--enable-lv2 \
--enable-nonfree \
--enable-nvdec \
--enable-nvenc \
--enable-openal \
--enable-opencl \
--enable-opengl \
--enable-outdev=alsa \
--enable-protocol=file \
--enable-shared \
--enable-small \
--enable-static \
--enable-vaapi \
--enable-vdpau \
--enable-version3 \
--enable-zlib \
--extra-cflags=-I/usr/local/cuda/include \
--extra-ldflags=-L/usr/local/cuda/lib64 \
--extra-libs=-lm \
--extra-libs=-lpthread
make -j16
make alltools
make install
cd "$rdir"
#Build and Install OpenCV
unzip opencv-$ocv_ver.zip
unzip opencv_contrib-$ocv_ver.zip
cd opencv-$ocv_ver/
mkdir build;cd build
cmake -D CMAKE_BUILD_TYPE=RELEASE \
-D CMAKE_INSTALL_PREFIX=/usr/local \
-D WITH_TBB=ON -D WITH_V4L=ON -D WITH_QT=OFF -D WITH_OPENGL=ON \
-D WITH_CUDA=ON \
-D ENABLE_FAST_MATH=1 \
-D CUDA_FAST_MATH=1 \
-D WITH_CUBLAS=1 \
-D BUILD_TESTS=OFF \
-D BUILD_PERF_TESTS=OFF \
-D OPENCV_GENERATE_PKGCONFIG=YES \
-D BUILD_opencv_apps=OFF \
-D OPENCV_EXTRA_MODULES_PATH="$rdir"/opencv_contrib-$ocv_ver/modules .. \
-D BUILD_EXAMPLES=OFF ..
sudo make -j16 install
cd "$rdir"