-
Notifications
You must be signed in to change notification settings - Fork 2
/
Dockerfile
93 lines (82 loc) · 2.77 KB
/
Dockerfile
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
FROM nvcr.io/nvidia/pytorch:23.03-py3
LABEL maintainer="Konstantin Schürholt <konstantin.schuerholt@unisg.ch>"
# based on https://github.com/JulianAssmann/opencv-cuda-docker
USER root
RUN apt-get update
# FFCV requires opencv, which is not available in the pytorch docker image.
# Installing via apt messes up cuda/mpi, so we need to build opencv from source.
# -> build opencv from source, with cuda (DWITH_CUDA=ON)
# -> pkg_config needs to be generated for ffcv to find opencv (DOPENCV_GENERATE_PKGCONFIG=YES) #note, can be "ON" depending on opencv version
ARG DEBIAN_FRONTEND=noninteractive
ARG OPENCV_VERSION=4.7.0
RUN apt-get update && apt-get upgrade -y &&\
# Install build tools, build dependencies and python
apt-get install -y \
python3-pip \
build-essential \
cmake \
git \
wget \
unzip \
yasm \
pkg-config \
libswscale-dev \
libtbb2 \
libtbb-dev \
libjpeg-dev \
libpng-dev \
libtiff-dev \
libavformat-dev \
libpq-dev \
libxine2-dev \
libglew-dev \
libtiff5-dev \
zlib1g-dev \
libjpeg-dev \
libavcodec-dev \
libavformat-dev \
libavutil-dev \
libpostproc-dev \
libswscale-dev \
libeigen3-dev \
libtbb-dev \
libgtk2.0-dev \
pkg-config \
## Python
python3-dev \
python3-numpy \
&& rm -rf /var/lib/apt/lists/*
RUN cd /opt/ &&\
# Download and unzip OpenCV and opencv_contrib and delte zip files
wget https://github.com/opencv/opencv/archive/$OPENCV_VERSION.zip &&\
unzip $OPENCV_VERSION.zip &&\
rm $OPENCV_VERSION.zip &&\
wget https://github.com/opencv/opencv_contrib/archive/$OPENCV_VERSION.zip &&\
unzip ${OPENCV_VERSION}.zip &&\
rm ${OPENCV_VERSION}.zip &&\
# Create build folder and switch to it
mkdir /opt/opencv-${OPENCV_VERSION}/build && cd /opt/opencv-${OPENCV_VERSION}/build &&\
# Cmake configure
cmake \
-DOPENCV_EXTRA_MODULES_PATH=/opt/opencv_contrib-${OPENCV_VERSION}/modules \
-DWITH_CUDA=ON \
-DCUDA_ARCH_BIN=7.5,8.0,8.6 \
-DCMAKE_BUILD_TYPE=RELEASE \
-DOPENCV_GENERATE_PKGCONFIG=YES \
# Install path will be /usr/local/lib (lib is implicit)
-DCMAKE_INSTALL_PREFIX=/usr/local \
.. &&\
# Make
make -j"$(nproc)" && \
# Install to /usr/local/lib
make install && \
ldconfig &&\
# Remove OpenCV sources and build folder
rm -rf /opt/opencv-${OPENCV_VERSION} && rm -rf /opt/opencv_contrib-${OPENCV_VERSION}
# install othere ffcv dependencies
RUN pip3 install cupy-cuda113 numba
RUN apt-get update -y
RUN apt-get install -y libturbojpeg0-dev
# install ffcv
RUN pip3 install ffcv
# add further packages below.