Skip to content

Commit ef39c32

Browse files
author
Fizmath
committed
Ampere Arch
0 parents  commit ef39c32

File tree

3 files changed

+328
-0
lines changed

3 files changed

+328
-0
lines changed

Dockerfile

+141
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,141 @@
1+
ARG CUDA_VERSION=11.7.0
2+
ARG CUDNN_VERSION=8
3+
ARG UBUNTU_VERSION=20.04
4+
5+
6+
FROM nvidia/cuda:${CUDA_VERSION}-cudnn${CUDNN_VERSION}-devel-ubuntu${UBUNTU_VERSION}
7+
LABEL mantainer=" github.com/Fizmath "
8+
9+
ARG PYTHON_VERSION=3.9
10+
ARG OPENCV_VERSION=4.6.0
11+
12+
ENV DEBIAN_FRONTEND=noninteractive
13+
14+
RUN apt-get -qq update && \
15+
apt-get -qq install \
16+
# python :
17+
python${PYTHON_VERSION} \
18+
python${PYTHON_VERSION}-dev \
19+
libpython${PYTHON_VERSION} \
20+
libpython${PYTHON_VERSION}-dev \
21+
python-dev \
22+
python3-setuptools \
23+
# developement tools, opencv image/video/GUI dependencies, optimiztion packages , etc ... :
24+
apt-utils \
25+
autoconf \
26+
automake \
27+
checkinstall \
28+
cmake \
29+
gfortran \
30+
git \
31+
libatlas-base-dev \
32+
libavcodec-dev \
33+
libavformat-dev \
34+
libavresample-dev \
35+
libeigen3-dev \
36+
libexpat1-dev \
37+
libglew-dev \
38+
libgtk-3-dev \
39+
libjpeg-dev \
40+
libopenexr-dev \
41+
libpng-dev \
42+
libpostproc-dev \
43+
libpq-dev \
44+
libqt5opengl5-dev \
45+
libsm6 \
46+
libswscale-dev \
47+
libtbb2 \
48+
libtbb-dev \
49+
libtiff-dev \
50+
libtool \
51+
libv4l-dev \
52+
libwebp-dev \
53+
libxext6 \
54+
libxrender1 \
55+
libxvidcore-dev \
56+
pkg-config \
57+
protobuf-compiler \
58+
qt5-default \
59+
unzip \
60+
wget \
61+
yasm \
62+
zlib1g-dev \
63+
# GStreamer :
64+
libgstreamer1.0-0 \
65+
gstreamer1.0-plugins-base \
66+
gstreamer1.0-plugins-good \
67+
gstreamer1.0-plugins-bad \
68+
gstreamer1.0-plugins-ugly \
69+
gstreamer1.0-libav \
70+
gstreamer1.0-doc \
71+
gstreamer1.0-tools \
72+
gstreamer1.0-x \
73+
gstreamer1.0-alsa \
74+
gstreamer1.0-gl \
75+
gstreamer1.0-gtk3 \
76+
gstreamer1.0-qt5 \
77+
gstreamer1.0-pulseaudio \
78+
libgstreamer1.0-dev \
79+
libgstreamer-plugins-base1.0-dev && \
80+
rm -rf /var/lib/apt/lists/* && \
81+
apt-get purge --auto-remove && \
82+
apt-get clean
83+
84+
# install new pyhton system wide :
85+
RUN update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.8 1 && \
86+
update-alternatives --install /usr/bin/python3 python3 /usr/bin/python${PYTHON_VERSION} 2 && \
87+
update-alternatives --config python3
88+
89+
# numpy for the newly installed python :
90+
RUN wget https://bootstrap.pypa.io/get-pip.py && \
91+
python${PYTHON_VERSION} get-pip.py --no-setuptools --no-wheel && \
92+
rm get-pip.py && \
93+
pip install numpy
94+
95+
# opencv and opencv-contrib :
96+
RUN cd /opt/ &&\
97+
wget https://github.com/opencv/opencv/archive/${OPENCV_VERSION}.zip -O opencv.zip &&\
98+
unzip -qq opencv.zip &&\
99+
rm opencv.zip &&\
100+
wget https://github.com/opencv/opencv_contrib/archive/${OPENCV_VERSION}.zip -O opencv-co.zip &&\
101+
unzip -qq opencv-co.zip &&\
102+
rm opencv-co.zip &&\
103+
mkdir /opt/opencv-${OPENCV_VERSION}/build && cd /opt/opencv-${OPENCV_VERSION}/build &&\
104+
cmake \
105+
-D BUILD_opencv_java=OFF \
106+
-D WITH_CUDA=ON \
107+
-D BUILD_opencv_dnn=ON \
108+
-D CUDA_ARCH_BIN=8.6 \
109+
-D CUDA_ARCH_PTX=8.6 \
110+
-D WITH_CUBLAS=ON \
111+
-D WITH_CUDNN=ON \
112+
-D OPENCV_DNN_CUDA=ON \
113+
-D ENABLE_FAST_MATH=1\
114+
-D CUDA_FAST_MATH=1\
115+
-D WITH_NVCUVID=ON \
116+
-D WITH_CUFFT=ON \
117+
-D WITH_OPENGL=ON \
118+
-D WITH_QT=ON \
119+
-D WITH_IPP=ON \
120+
-D WITH_TBB=ON \
121+
-D WITH_EIGEN=ON \
122+
-D CUDA_NVCC_FLAGS=-Wno-deprecated-gpu-targets \
123+
-D CMAKE_BUILD_TYPE=RELEASE \
124+
-D OPENCV_EXTRA_MODULES_PATH=/opt/opencv_contrib-${OPENCV_VERSION}/modules \
125+
-D PYTHON2_EXECUTABLE=$(python${PYTHON_VERSION} -c "import sys; print(sys.prefix)") \
126+
-D CMAKE_INSTALL_PREFIX=$(python${PYTHON_VERSION} -c "import sys; print(sys.prefix)") \
127+
-D PYTHON_EXECUTABLE=$(which python${PYTHON_VERSION}) \
128+
-D PYTHON_INCLUDE_DIR=$(python${PYTHON_VERSION} -c "from distutils.sysconfig import get_python_inc; print(get_python_inc())") \
129+
-D PYTHON3_PACKAGES_PATH=/usr/lib/python${PYTHON_VERSION}/dist-packages \
130+
-D CUDA_TOOLKIT_ROOT_DIR=/usr/local/cuda-11.7 \
131+
-D CMAKE_LIBRARY_PATH=/usr/local/cuda/lib64/stubs \
132+
.. &&\
133+
make -j$(nproc) && \
134+
make install && \
135+
ldconfig &&\
136+
rm -rf /opt/opencv-${OPENCV_VERSION} && rm -rf /opt/opencv_contrib-${OPENCV_VERSION}
137+
138+
ENV NVIDIA_DRIVER_CAPABILITIES all
139+
ENV XDG_RUNTIME_DIR "/tmp"
140+
141+
WORKDIR /myapp

README.md

+59
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
2+
3+
# GPU-accelerated Docker container with OpenCV 4.6, Python 3.9, GStreamer and CUDA 11.7
4+
5+
- [opencv](https://github.com/opencv/opencv) + [opencv_contrib](https://github.com/opencv/opencv_contrib)
6+
- Python 3.9.5
7+
- Ubuntu 20.04
8+
- GStreamer 1.16.3
9+
- FFMPEG
10+
- CUDA 11.7.0
11+
- NVIDIA GPU Compute Capability: sm_86 ( single arch build ; the container wokrs with **NVIDIA Ampere GPUs** RTX 30 series. For older GPUs see this repo)
12+
- cuDNN: 8.5.0
13+
- OpenCL
14+
- Qt5::OpenGL 5.12.8
15+
- Intel IPP and TBB
16+
- UNCOMPRESSED SIZE 8.32 GB
17+
18+
19+
## How to build :
20+
21+
Unlike the [older repo](https://github.com/Fizmath/Docker-opencv-GPU) there is no pre-built container in the DockerHub so you should build it in your local mcachine. Since it is a single arch build i.e sm_86, it builds faster about 15 minutes with 16 core CPU. Open your CMD in the folder where you have the [Dockerfile](Dockerfile) then run this command :
22+
23+
24+
```bash
25+
$ docker build -f Dockerfile -t <name>:<tag> .
26+
```
27+
You will also see some ignorable deprecation warnings.
28+
29+
## Test the container with the examples in the [older repo](https://github.com/Fizmath/Docker-opencv-GPU) :
30+
31+
The work through how to run and test some examples is in that repo. The only thing you need to do is to replace the older image name ``fizmath/gpu-opencv:latest`` with yours ``` <name>:<tag> ``` .
32+
33+
## CUDA backend crashing issue :
34+
For the tests 5 and 6 : Real-time face detection with OpenCV DNN and object detection with YOLO v4 you will get this error :
35+
36+
```
37+
global /opt/opencv-4.6.0/modules/dnn/src/op_cuda.cpp (80)
38+
39+
initCUDABackend CUDA backend will fallback to the CPU implementation for the layer "_input" of type __NetInputLayer__
40+
41+
```
42+
Check out the [source code ](https://github.com/opencv/opencv/blob/ 3eeec4faae0c8b020d0efd30a51c1e97a0f444a5/modules/dnn/src/dnn.cpp#L2854) for this error
43+
44+
You can see this erro by typing `` export OPENCV_LOG_LEVEL=INFO `` in the container's shell .
45+
46+
I also tried some of the newest models from [OpenCV Zoo](https://github.com/opencv/opencv_zoo). BUT, again got the same CUDA backend crashings.
47+
48+
49+
That error crashes the inference with the GPU. The reason behind this might be that OpenCV DNN models are not compatile with the new **NVIDIA Ampere GPUs** architecture or some other issues ...
50+
51+
52+
If you run the container with CPU, you see that the DNN models work fine with the INTEL TBB and IPP with full CPU cores usage.
53+
54+
55+
If you solve this problem please open up an issue to discuss .
56+
57+
Thanks .
58+
59+

cv2_Build_Info

+128
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,128 @@
1+
2+
General configuration for OpenCV 4.6.0 =====================================
3+
Version control: unknown
4+
5+
Extra modules:
6+
Location (extra): /opt/opencv_contrib-4.6.0/modules
7+
Version control (extra): unknown
8+
9+
Platform:
10+
Timestamp: 2022-09-30T19:14:07Z
11+
Host: Linux 5.15.0-48-generic x86_64
12+
CMake: 3.16.3
13+
CMake generator: Unix Makefiles
14+
CMake build tool: /usr/bin/make
15+
Configuration: RELEASE
16+
17+
CPU/HW features:
18+
Baseline: SSE SSE2 SSE3
19+
requested: SSE3
20+
Dispatched code generation: SSE4_1 SSE4_2 FP16 AVX AVX2 AVX512_SKX
21+
requested: SSE4_1 SSE4_2 AVX FP16 AVX2 AVX512_SKX
22+
SSE4_1 (18 files): + SSSE3 SSE4_1
23+
SSE4_2 (2 files): + SSSE3 SSE4_1 POPCNT SSE4_2
24+
FP16 (1 files): + SSSE3 SSE4_1 POPCNT SSE4_2 FP16 AVX
25+
AVX (5 files): + SSSE3 SSE4_1 POPCNT SSE4_2 AVX
26+
AVX2 (33 files): + SSSE3 SSE4_1 POPCNT SSE4_2 FP16 FMA3 AVX AVX2
27+
AVX512_SKX (8 files): + SSSE3 SSE4_1 POPCNT SSE4_2 FP16 FMA3 AVX AVX2 AVX_512F AVX512_COMMON AVX512_SKX
28+
29+
C/C++:
30+
Built as dynamic libs?: YES
31+
C++ standard: 11
32+
C++ Compiler: /usr/bin/c++ (ver 9.4.0)
33+
C++ flags (Release): -fsigned-char -ffast-math -W -Wall -Wreturn-type -Wnon-virtual-dtor -Waddress -Wsequence-point -Wformat -Wformat-security -Wmissing-declarations -Wundef -Winit-self -Wpointer-arith -Wshadow -Wsign-promo -Wuninitialized -Wsuggest-override -Wno-delete-non-virtual-dtor -Wno-comment -Wimplicit-fallthrough=3 -Wno-strict-overflow -fdiagnostics-show-option -Wno-long-long -pthread -fomit-frame-pointer -ffunction-sections -fdata-sections -msse -msse2 -msse3 -fvisibility=hidden -fvisibility-inlines-hidden -O3 -DNDEBUG -DNDEBUG
34+
C++ flags (Debug): -fsigned-char -ffast-math -W -Wall -Wreturn-type -Wnon-virtual-dtor -Waddress -Wsequence-point -Wformat -Wformat-security -Wmissing-declarations -Wundef -Winit-self -Wpointer-arith -Wshadow -Wsign-promo -Wuninitialized -Wsuggest-override -Wno-delete-non-virtual-dtor -Wno-comment -Wimplicit-fallthrough=3 -Wno-strict-overflow -fdiagnostics-show-option -Wno-long-long -pthread -fomit-frame-pointer -ffunction-sections -fdata-sections -msse -msse2 -msse3 -fvisibility=hidden -fvisibility-inlines-hidden -g -O0 -DDEBUG -D_DEBUG
35+
C Compiler: /usr/bin/cc
36+
C flags (Release): -fsigned-char -ffast-math -W -Wall -Wreturn-type -Waddress -Wsequence-point -Wformat -Wformat-security -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wundef -Winit-self -Wpointer-arith -Wshadow -Wuninitialized -Wno-comment -Wimplicit-fallthrough=3 -Wno-strict-overflow -fdiagnostics-show-option -Wno-long-long -pthread -fomit-frame-pointer -ffunction-sections -fdata-sections -msse -msse2 -msse3 -fvisibility=hidden -O3 -DNDEBUG -DNDEBUG
37+
C flags (Debug): -fsigned-char -ffast-math -W -Wall -Wreturn-type -Waddress -Wsequence-point -Wformat -Wformat-security -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wundef -Winit-self -Wpointer-arith -Wshadow -Wuninitialized -Wno-comment -Wimplicit-fallthrough=3 -Wno-strict-overflow -fdiagnostics-show-option -Wno-long-long -pthread -fomit-frame-pointer -ffunction-sections -fdata-sections -msse -msse2 -msse3 -fvisibility=hidden -g -O0 -DDEBUG -D_DEBUG
38+
Linker flags (Release): -Wl,--exclude-libs,libippicv.a -Wl,--exclude-libs,libippiw.a -Wl,--gc-sections -Wl,--as-needed -Wl,--no-undefined
39+
Linker flags (Debug): -Wl,--exclude-libs,libippicv.a -Wl,--exclude-libs,libippiw.a -Wl,--gc-sections -Wl,--as-needed -Wl,--no-undefined
40+
ccache: NO
41+
Precompiled headers: NO
42+
Extra dependencies: m pthread cudart_static dl rt nppc nppial nppicc nppidei nppif nppig nppim nppist nppisu nppitc npps cublas cudnn cufft -L/usr/local/cuda-11.7/lib64 -L/usr/lib/x86_64-linux-gnu
43+
3rdparty dependencies:
44+
45+
OpenCV modules:
46+
To be built: alphamat aruco barcode bgsegm bioinspired calib3d ccalib core cudaarithm cudabgsegm cudacodec cudafeatures2d cudafilters cudaimgproc cudalegacy cudaobjdetect cudaoptflow cudastereo cudawarping cudev cvv datasets dnn dnn_objdetect dnn_superres dpm face features2d flann freetype fuzzy gapi hfs highgui img_hash imgcodecs imgproc intensity_transform line_descriptor mcc ml objdetect optflow phase_unwrapping photo plot python3 quality rapid reg rgbd saliency shape stereo stitching structured_light superres surface_matching text tracking ts video videoio videostab wechat_qrcode xfeatures2d ximgproc xobjdetect xphoto
47+
Disabled: world
48+
Disabled by dependency: -
49+
Unavailable: hdf java julia matlab ovis python2 sfm viz
50+
Applications: tests perf_tests apps
51+
Documentation: NO
52+
Non-free algorithms: NO
53+
54+
GUI: QT5
55+
QT: YES (ver 5.12.8 )
56+
QT OpenGL support: YES (Qt5::OpenGL 5.12.8)
57+
GTK+: YES (ver 3.24.20)
58+
GThread : YES (ver 2.64.6)
59+
GtkGlExt: NO
60+
OpenGL support: YES (/usr/lib/x86_64-linux-gnu/libGL.so /usr/lib/x86_64-linux-gnu/libGLU.so)
61+
VTK support: NO
62+
63+
Media I/O:
64+
ZLib: /usr/lib/x86_64-linux-gnu/libz.so (ver 1.2.11)
65+
JPEG: /usr/lib/x86_64-linux-gnu/libjpeg.so (ver 80)
66+
WEBP: /usr/lib/x86_64-linux-gnu/libwebp.so (ver encoder: 0x020e)
67+
PNG: /usr/lib/x86_64-linux-gnu/libpng.so (ver 1.6.37)
68+
TIFF: /usr/lib/x86_64-linux-gnu/libtiff.so (ver 42 / 4.1.0)
69+
JPEG 2000: build (ver 2.4.0)
70+
OpenEXR: /usr/lib/x86_64-linux-gnu/libImath.so /usr/lib/x86_64-linux-gnu/libIlmImf.so /usr/lib/x86_64-linux-gnu/libIex.so /usr/lib/x86_64-linux-gnu/libHalf.so /usr/lib/x86_64-linux-gnu/libIlmThread.so (ver 2_3)
71+
HDR: YES
72+
SUNRASTER: YES
73+
PXM: YES
74+
PFM: YES
75+
76+
Video I/O:
77+
DC1394: NO
78+
FFMPEG: YES
79+
avcodec: YES (58.54.100)
80+
avformat: YES (58.29.100)
81+
avutil: YES (56.31.100)
82+
swscale: YES (5.5.100)
83+
avresample: YES (4.0.0)
84+
GStreamer: YES (1.16.3)
85+
v4l/v4l2: YES (linux/videodev2.h)
86+
87+
Parallel framework: TBB (ver 2020.1 interface 11101)
88+
89+
Trace: YES (with Intel ITT)
90+
91+
Other third-party libraries:
92+
Intel IPP: 2020.0.0 Gold [2020.0.0]
93+
at: /opt/opencv-4.6.0/build/3rdparty/ippicv/ippicv_lnx/icv
94+
Intel IPP IW: sources (2020.0.0)
95+
at: /opt/opencv-4.6.0/build/3rdparty/ippicv/ippicv_lnx/iw
96+
VA: NO
97+
Lapack: NO
98+
Eigen: YES (ver 3.3.7)
99+
Custom HAL: NO
100+
Protobuf: build (3.19.1)
101+
102+
NVIDIA CUDA: YES (ver 11.7, CUFFT CUBLAS FAST_MATH)
103+
NVIDIA GPU arch: 86
104+
NVIDIA PTX archs: 86
105+
106+
cuDNN: YES (ver 8.5.0)
107+
108+
OpenCL: YES (no extra features)
109+
Include path: /opt/opencv-4.6.0/3rdparty/include/opencl/1.2
110+
Link libraries: Dynamic load
111+
112+
Python 3:
113+
Interpreter: /usr/bin/python3 (ver 3.9.5)
114+
Libraries: /usr/lib/x86_64-linux-gnu/libpython3.9.so (ver 3.9.5)
115+
numpy: /usr/local/lib/python3.9/dist-packages/numpy/core/include (ver 1.23.3)
116+
install path: /usr/lib/python3.9/dist-packages/cv2/python-3.9
117+
118+
Python (for build): /usr/bin/python3
119+
120+
Java:
121+
ant: NO
122+
JNI: NO
123+
Java wrappers: NO
124+
Java tests: NO
125+
126+
Install to: /usr
127+
-----------------------------------------------------------------
128+

0 commit comments

Comments
 (0)