Skip to content

Commit 5954401

Browse files
authored
bump: update Ubuntu & drop python 2.x (#53)
1 parent f7f053a commit 5954401

File tree

6 files changed

+59
-110
lines changed

6 files changed

+59
-110
lines changed

.github/ISSUE_TEMPLATE/bug_report.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ assignees: ''
1515
Steps to reproduce the behavior:
1616

1717
1. Go to '...'
18-
1. Run '....'
19-
1. See error
18+
2. Run '....'
19+
3. See error
2020

2121
<!-- If you have a code sample, error messages, stack traces, please provide it here as well -->
2222

.github/workflows/docker-builds.yml

Lines changed: 11 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -17,37 +17,20 @@ jobs:
1717
strategy:
1818
fail-fast: false
1919
matrix:
20-
ubuntu_version: ["20.04"]
21-
python_version: ["2.7", "3.6", "3.7", "3.8", "3.9"]
20+
ubuntu_version: ["22.04"]
21+
python_version: ["3.8", "3.9", "3.10", "3.11", "3.12", "3.13"]
2222
opencv_version: ["4.10.0"]
2323
device: ["cpu", "gpu"]
24-
cuda_version: ["11.8.0"]
24+
cuda_version: ["12.4.1"]
2525
include:
26-
- { ubuntu_version: "22.04", python_version: "3.10", opencv_version: "4.10.0", device: "cpu" }
27-
- { ubuntu_version: "22.04", python_version: "3.11", opencv_version: "4.10.0", device: "cpu" }
28-
# fixme: python 3.12 install fails due to wring public keys to deadsnakes
29-
# - { ubuntu_version: "22.04", python_version: "3.12", opencv_version: "4.10.0", device: "cpu" }
30-
- {
31-
ubuntu_version: "22.04",
32-
python_version: "3.10",
33-
opencv_version: "4.10.0",
34-
device: "gpu",
35-
cuda_version: "12.5.0",
36-
}
37-
- {
38-
ubuntu_version: "22.04",
39-
python_version: "3.11",
40-
opencv_version: "4.10.0",
41-
device: "gpu",
42-
cuda_version: "12.5.0",
43-
}
44-
- {
45-
ubuntu_version: "22.04",
46-
python_version: "3.12",
47-
opencv_version: "4.10.0",
48-
device: "gpu",
49-
cuda_version: "12.5.0",
50-
}
26+
- { ubuntu_version: "24.04", python_version: "3.10", opencv_version: "4.10.0", device: "cpu" }
27+
- { ubuntu_version: "24.04", python_version: "3.11", opencv_version: "4.10.0", device: "cpu" }
28+
#- { ubuntu_version: "24.04", python_version: "3.12", opencv_version: "4.10.0", device: "cpu" }
29+
- { ubuntu_version: "24.04", python_version: "3.13", opencv_version: "4.10.0", device: "cpu" }
30+
- { ubuntu_version: "24.04", python_version: "3.10", opencv_version: "4.10.0", device: "gpu", cuda_version: "12.8.0" }
31+
- { ubuntu_version: "24.04", python_version: "3.11", opencv_version: "4.10.0", device: "gpu", cuda_version: "12.8.0" }
32+
#- { ubuntu_version: "24.04", python_version: "3.12", opencv_version: "4.10.0", device: "gpu", cuda_version: "12.8.0" }
33+
- { ubuntu_version: "24.04", python_version: "3.13", opencv_version: "4.10.0", device: "gpu", cuda_version: "12.8.0" }
5134
steps:
5235
- name: Checkout
5336
uses: actions/checkout@v4

.pre-commit-config.yaml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
default_language_version:
2+
python: python3
3+
14
ci:
25
autofix_prs: true
36
autoupdate_commit_msg: "[pre-commit.ci] pre-commit suggestions"
@@ -23,9 +26,10 @@ repos:
2326
- id: codespell
2427

2528
- repo: https://github.com/executablebooks/mdformat
26-
rev: 0.7.16
29+
rev: 0.7.17
2730
hooks:
2831
- id: mdformat
32+
args: ["--number"]
2933
additional_dependencies:
3034
- mdformat-gfm
3135
- mdformat_frontmatter
@@ -41,4 +45,4 @@ repos:
4145
- id: prettier
4246
files: \.(json|yml|yaml|toml)
4347
# https://prettier.io/docs/en/options.html#print-width
44-
args: ["--print-width=120"]
48+
args: ["--print-width=140"]

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
# Docker: Python-OpenCV-FFmpeg(-CUDA)
22

3-
Repository for clean Dockerfile containing [FFmpeg](https://www.ffmpeg.org/), [OpenCV4](https://opencv.org/) and [Python2/3](https://www.python.org/), based on [Ubuntu](https://www.ubuntu.com/) 22.04 LTS.
3+
Repository for clean Dockerfile containing [FFmpeg](https://www.ffmpeg.org/), [OpenCV4](https://opencv.org/) and [Python3](https://www.python.org/), based on [Ubuntu](https://www.ubuntu.com/) 24.04 LTS.
44

55
## Tags
66

7-
- `:cpu-pyX.y-cvX.y.z` for Python 2.x/3.x, OpenCV 4.10.x, FFmpeg
8-
- `:gpu-pyX.y-cvX.y.z` for Python 2.x/3.x, OpenCV 4.10.x, FFmpeg with CUDA 11.4 support
7+
- `:cpu-pyX.y-cvX.y.z` for Python 3.x, OpenCV 4.10.x, FFmpeg
8+
- `:gpu-pyX.y-cvX.y.z` for Python 3.x, OpenCV 4.10.x, FFmpeg with CUDA 12.x support
99

1010
## Build
1111

cpu/Dockerfile

Lines changed: 21 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -18,35 +18,26 @@ ENV DEBIAN_FRONTEND=noninteractive \
1818

1919

2020
RUN \
21-
# add sources for older pythons
22-
apt-get update -q --fix-missing && \
23-
apt-get install -y --no-install-recommends software-properties-common && \
24-
if [[ "$PYTHON_VERSION" =~ ^(2.7|3.6|3.7|3.12)$ ]]; then \
25-
add-apt-repository ppa:deadsnakes/ppa ; \
26-
fi && \
21+
apt-get update -qq --fix-missing && \
22+
apt-get install -y --no-install-recommends \
23+
software-properties-common \
24+
dirmngr \
25+
gnupg && \
26+
add-apt-repository ppa:deadsnakes/ppa && \
2727
apt-add-repository universe && \
2828
apt-get -y update -qq --fix-missing && \
2929
apt-get -y install --no-install-recommends \
3030
python${PYTHON_VERSION} \
3131
python${PYTHON_VERSION}-dev \
32-
$( [ ${PYTHON_VERSION%%.*} -ge 3 ] && echo "python${PYTHON_VERSION}-distutils" ) \
32+
$( if [ "${PYTHON_VERSION%%.*}" -eq 3 ] && [ "${PYTHON_VERSION#*.}" -lt 10 ]; then echo "python${PYTHON_VERSION}-distutils"; fi ) \
3333
curl \
34-
wget \
35-
&& \
34+
wget && \
3635
rm -rf /var/lib/apt/lists/* && \
37-
3836
# Set the default python and install PIP packages
3937
update-alternatives --install /usr/bin/python${PYTHON_VERSION%%.*} python${PYTHON_VERSION%%.*} /usr/bin/python${PYTHON_VERSION} 1 && \
4038
update-alternatives --install /usr/bin/python python /usr/bin/python${PYTHON_VERSION} 1 && \
41-
42-
# install python dependencies
43-
# sysctl -w net.ipv4.ip_forward=1 ; \
44-
if [[ "$PYTHON_VERSION" == "2.7" || "$PYTHON_VERSION" == "3.6" || "$PYTHON_VERSION" == "3.7" ]]; then \
45-
PIP_URL="https://bootstrap.pypa.io/pip/$PYTHON_VERSION/get-pip.py" ; \
46-
else \
47-
apt-get -y install --no-install-recommends python${PYTHON_VERSION}-distutils ; \
48-
PIP_URL="https://bootstrap.pypa.io/get-pip.py" ; \
49-
fi && \
39+
# install python dependencies \
40+
PIP_URL="https://bootstrap.pypa.io/get-pip.py" && \
5041
curl $PIP_URL | python
5142

5243
ENV PYTHONPATH="/usr/lib/python${PYTHON_VERSION}/site-packages:/usr/local/lib/python${PYTHON_VERSION}/site-packages"
@@ -58,15 +49,12 @@ RUN \
5849
unzip \
5950
cmake \
6051
ffmpeg \
61-
$( [ "$UBUNTU_VERSION" = "20.04" ] && libtbb2 || libtbb12 ) \
6252
gfortran \
6353
apt-utils \
6454
pkg-config \
6555
checkinstall \
6656
qtbase5-dev qt5-qmake \
6757
build-essential \
68-
libopenblas-base \
69-
libopenblas-dev \
7058
liblapack-dev \
7159
libatlas-base-dev \
7260
libavcodec-dev \
@@ -89,21 +77,18 @@ RUN \
8977
zlib1g-dev \
9078
libsm6 \
9179
libxext6 \
92-
libxrender1 \
93-
&& \
80+
libxrender1 && \
9481
pip install numpy && \
95-
96-
# Install OpenCV
82+
# Install OpenCV
9783
wget https://github.com/opencv/opencv/archive/${OPENCV_VERSION}.zip -O opencv.zip --progress=bar:force:noscroll --no-check-certificate && \
9884
unzip -q opencv.zip && \
99-
mv /opencv-${OPENCV_VERSION} /opencv && \
85+
mv opencv-${OPENCV_VERSION} /opencv && \
10086
rm opencv.zip && \
10187
wget https://github.com/opencv/opencv_contrib/archive/${OPENCV_VERSION}.zip -O opencv_contrib.zip --progress=bar:force:noscroll --no-check-certificate && \
10288
unzip -q opencv_contrib.zip && \
103-
mv /opencv_contrib-${OPENCV_VERSION} /opencv_contrib && \
89+
mv opencv_contrib-${OPENCV_VERSION} /opencv_contrib && \
10490
rm opencv_contrib.zip && \
105-
106-
# Prepare build
91+
# Prepare build
10792
mkdir /opencv/build && \
10893
cd /opencv/build && \
10994
cmake \
@@ -114,8 +99,8 @@ RUN \
11499
-D BUILD_TESTS=OFF \
115100
-D CMAKE_INSTALL_PREFIX=/usr/local \
116101
-D OPENCV_EXTRA_MODULES_PATH=/opencv_contrib/modules \
117-
-D BUILD_opencv_python3=$( [ ${PYTHON_VERSION%%.*} -ge 3 ] && echo "ON" || echo "OFF" ) \
118-
-D BUILD_opencv_python2=$( [ ${PYTHON_VERSION%%.*} -lt 3 ] && echo "ON" || echo "OFF" ) \
102+
-D BUILD_opencv_python3=ON \
103+
-D BUILD_opencv_python2=OFF \
119104
-D PYTHON${PYTHON_VERSION%%.*}_EXECUTABLE=$(which python${PYTHON_VERSION}) \
120105
-D PYTHON_DEFAULT_EXECUTABLE=$(which python${PYTHON_VERSION}) \
121106
-D BUILD_EXAMPLES=OFF \
@@ -130,16 +115,13 @@ RUN \
130115
-D WITH_LAPACK=ON \
131116
#-D WITH_HPX=ON \
132117
-D ENABLE_PRECOMPILED_HEADERS=OFF \
133-
.. \
134-
&& \
135-
136-
# Build, Test and Install
118+
.. && \
119+
# Build, Test and Install
137120
cd /opencv/build && \
138121
make -j$(nproc) && \
139122
make install && \
140123
ldconfig && \
141-
142-
# cleaning
124+
# cleaning
143125
apt-get -y remove \
144126
unzip \
145127
cmake \
@@ -148,7 +130,6 @@ RUN \
148130
pkg-config \
149131
checkinstall \
150132
build-essential \
151-
libopenblas-dev \
152133
liblapack-dev \
153134
libatlas-base-dev \
154135
libavcodec-dev \
@@ -165,8 +146,7 @@ RUN \
165146
libglew-dev \
166147
libpostproc-dev \
167148
libeigen3-dev \
168-
zlib1g-dev \
169-
&& \
149+
zlib1g-dev && \
170150
apt-get autoremove -y && \
171151
apt-get clean && \
172152
rm -rf /opencv /opencv_contrib /var/lib/apt/lists/*

gpu/Dockerfile

Lines changed: 16 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -24,35 +24,26 @@ ENV DEBIAN_FRONTEND=noninteractive \
2424
# ENV LD_LIBRARY_PATH /usr/local/${CUDA}/compat:$LD_LIBRARY_PATH
2525

2626
RUN \
27-
# add sources for older pythons
2827
apt-get update -qq --fix-missing && \
29-
apt-get install -y --no-install-recommends software-properties-common && \
30-
if [[ "$PYTHON_VERSION" =~ ^(2.7|3.6|3.7|3.12)$ ]]; then \
31-
add-apt-repository ppa:deadsnakes/ppa ; \
32-
fi && \
28+
apt-get install -y --no-install-recommends \
29+
software-properties-common \
30+
dirmngr \
31+
gnupg && \
32+
add-apt-repository ppa:deadsnakes/ppa && \
3333
apt-add-repository universe && \
3434
apt-get -y update -qq --fix-missing && \
3535
apt-get -y install --no-install-recommends \
3636
python${PYTHON_VERSION} \
3737
python${PYTHON_VERSION}-dev \
38-
$( [ ${PYTHON_VERSION%%.*} -ge 3 ] && echo "python${PYTHON_VERSION}-distutils" ) \
38+
$( if [ "${PYTHON_VERSION%%.*}" -eq 3 ] && [ "${PYTHON_VERSION#*.}" -lt 10 ]; then echo "python${PYTHON_VERSION}-distutils"; fi ) \
3939
curl \
40-
wget \
41-
&& \
40+
wget && \
4241
rm -rf /var/lib/apt/lists/* && \
43-
4442
# Set the default python and install PIP packages
4543
update-alternatives --install /usr/bin/python${PYTHON_VERSION%%.*} python${PYTHON_VERSION%%.*} /usr/bin/python${PYTHON_VERSION} 1 && \
4644
update-alternatives --install /usr/bin/python python /usr/bin/python${PYTHON_VERSION} 1 && \
47-
4845
# install python dependencies
49-
# sysctl -w net.ipv4.ip_forward=1 ; \
50-
if [[ "$PYTHON_VERSION" == "2.7" || "$PYTHON_VERSION" == "3.6" || "$PYTHON_VERSION" == "3.7" ]]; then \
51-
PIP_URL="https://bootstrap.pypa.io/pip/$PYTHON_VERSION/get-pip.py" ; \
52-
else \
53-
apt-get -y install --no-install-recommends python${PYTHON_VERSION}-distutils ; \
54-
PIP_URL="https://bootstrap.pypa.io/get-pip.py" ; \
55-
fi && \
46+
PIP_URL="https://bootstrap.pypa.io/get-pip.py" && \
5647
curl $PIP_URL | python
5748

5849
ENV PYTHONPATH="/usr/lib/python${PYTHON_VERSION}/site-packages:/usr/local/lib/python${PYTHON_VERSION}/site-packages"
@@ -63,22 +54,18 @@ RUN \
6354
CUDA=`basename $CUDA_PATH` && \
6455
echo "$CUDA_PATH/compat" >> /etc/ld.so.conf.d/${CUDA/./-}.conf && \
6556
ldconfig && \
66-
67-
# Install all dependencies for OpenCV
57+
# Install all dependencies for OpenCV
6858
apt-get -y update -qq --fix-missing && \
6959
apt-get -y install --no-install-recommends \
7060
unzip \
7161
cmake \
7262
ffmpeg \
73-
$( [ "$UBUNTU_VERSION" = "20.04" ] && libtbb2 || libtbb12 ) \
7463
gfortran \
7564
apt-utils \
7665
pkg-config \
7766
checkinstall \
7867
qtbase5-dev qt5-qmake \
7968
build-essential \
80-
libopenblas-base \
81-
libopenblas-dev \
8269
liblapack-dev \
8370
libatlas-base-dev \
8471
libavcodec-dev \
@@ -104,8 +91,7 @@ RUN \
10491
libxrender1 \
10592
&& \
10693
pip install numpy && \
107-
108-
# Install OpenCV
94+
# Install OpenCV
10995
wget https://github.com/opencv/opencv/archive/$OPENCV_VERSION.zip -O opencv.zip --progress=bar:force:noscroll && \
11096
unzip -q opencv.zip && \
11197
mv /opencv-$OPENCV_VERSION /opencv && \
@@ -114,8 +100,7 @@ RUN \
114100
unzip -q opencv_contrib.zip && \
115101
mv /opencv_contrib-$OPENCV_VERSION /opencv_contrib && \
116102
rm opencv_contrib.zip && \
117-
118-
# Prepare build
103+
# Prepare build
119104
mkdir /opencv/build && \
120105
cd /opencv/build && \
121106
cmake \
@@ -126,8 +111,8 @@ RUN \
126111
-D BUILD_TESTS=OFF \
127112
-D CMAKE_INSTALL_PREFIX=/usr/local \
128113
-D OPENCV_EXTRA_MODULES_PATH=/opencv_contrib/modules \
129-
-D BUILD_opencv_python3=$( [ ${PYTHON_VERSION%%.*} -ge 3 ] && echo "ON" || echo "OFF" ) \
130-
-D BUILD_opencv_python2=$( [ ${PYTHON_VERSION%%.*} -lt 3 ] && echo "ON" || echo "OFF" ) \
114+
-D BUILD_opencv_python3=ON \
115+
-D BUILD_opencv_python2=OFF \
131116
-D PYTHON${PYTHON_VERSION%%.*}_EXECUTABLE=$(which python${PYTHON_VERSION}) \
132117
-D PYTHON_DEFAULT_EXECUTABLE=$(which python${PYTHON_VERSION}) \
133118
-D BUILD_EXAMPLES=OFF \
@@ -148,21 +133,19 @@ RUN \
148133
# https://stackoverflow.com/questions/28010399/build-opencv-with-cuda-support
149134
-D CUDA_ARCH_BIN="5.3 6.1 7.0 7.5" \
150135
-D CUDA_ARCH_PTX="" \
151-
-D WITH_CUBLAS=ON \
136+
#-D WITH_CUBLAS=ON \
152137
-D WITH_NVCUVID=ON \
153138
-D ENABLE_FAST_MATH=1 \
154139
-D CUDA_FAST_MATH=1 \
155140
-D ENABLE_PRECOMPILED_HEADERS=OFF \
156141
.. \
157142
&& \
158-
159-
# Build, Test and Install
143+
# Build, Test and Install
160144
cd /opencv/build && \
161145
make -j$(nproc) && \
162146
make install && \
163147
ldconfig && \
164-
165-
# cleaning
148+
# cleaning
166149
apt-get -y remove \
167150
unzip \
168151
cmake \
@@ -171,7 +154,6 @@ RUN \
171154
pkg-config \
172155
checkinstall \
173156
build-essential \
174-
libopenblas-dev \
175157
liblapack-dev \
176158
libatlas-base-dev \
177159
libavcodec-dev \

0 commit comments

Comments
 (0)