Skip to content

bump: update Ubuntu & drop python 2.x #53

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 25 commits into from
Mar 19, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ assignees: ''
Steps to reproduce the behavior:

1. Go to '...'
1. Run '....'
1. See error
2. Run '....'
3. See error

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

Expand Down
39 changes: 11 additions & 28 deletions .github/workflows/docker-builds.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,37 +17,20 @@ jobs:
strategy:
fail-fast: false
matrix:
ubuntu_version: ["20.04"]
python_version: ["2.7", "3.6", "3.7", "3.8", "3.9"]
ubuntu_version: ["22.04"]
python_version: ["3.8", "3.9", "3.10", "3.11", "3.12", "3.13"]
opencv_version: ["4.10.0"]
device: ["cpu", "gpu"]
cuda_version: ["11.8.0"]
cuda_version: ["12.4.1"]
include:
- { ubuntu_version: "22.04", python_version: "3.10", opencv_version: "4.10.0", device: "cpu" }
- { ubuntu_version: "22.04", python_version: "3.11", opencv_version: "4.10.0", device: "cpu" }
# fixme: python 3.12 install fails due to wring public keys to deadsnakes
# - { ubuntu_version: "22.04", python_version: "3.12", opencv_version: "4.10.0", device: "cpu" }
- {
ubuntu_version: "22.04",
python_version: "3.10",
opencv_version: "4.10.0",
device: "gpu",
cuda_version: "12.5.0",
}
- {
ubuntu_version: "22.04",
python_version: "3.11",
opencv_version: "4.10.0",
device: "gpu",
cuda_version: "12.5.0",
}
- {
ubuntu_version: "22.04",
python_version: "3.12",
opencv_version: "4.10.0",
device: "gpu",
cuda_version: "12.5.0",
}
- { ubuntu_version: "24.04", python_version: "3.10", opencv_version: "4.10.0", device: "cpu" }
- { ubuntu_version: "24.04", python_version: "3.11", opencv_version: "4.10.0", device: "cpu" }
#- { ubuntu_version: "24.04", python_version: "3.12", opencv_version: "4.10.0", device: "cpu" }
- { ubuntu_version: "24.04", python_version: "3.13", opencv_version: "4.10.0", device: "cpu" }
- { ubuntu_version: "24.04", python_version: "3.10", opencv_version: "4.10.0", device: "gpu", cuda_version: "12.8.0" }
- { ubuntu_version: "24.04", python_version: "3.11", opencv_version: "4.10.0", device: "gpu", cuda_version: "12.8.0" }
#- { ubuntu_version: "24.04", python_version: "3.12", opencv_version: "4.10.0", device: "gpu", cuda_version: "12.8.0" }
- { ubuntu_version: "24.04", python_version: "3.13", opencv_version: "4.10.0", device: "gpu", cuda_version: "12.8.0" }
steps:
- name: Checkout
uses: actions/checkout@v4
Expand Down
8 changes: 6 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
default_language_version:
python: python3

ci:
autofix_prs: true
autoupdate_commit_msg: "[pre-commit.ci] pre-commit suggestions"
Expand All @@ -23,9 +26,10 @@ repos:
- id: codespell

- repo: https://github.com/executablebooks/mdformat
rev: 0.7.16
rev: 0.7.17
hooks:
- id: mdformat
args: ["--number"]
additional_dependencies:
- mdformat-gfm
- mdformat_frontmatter
Expand All @@ -41,4 +45,4 @@ repos:
- id: prettier
files: \.(json|yml|yaml|toml)
# https://prettier.io/docs/en/options.html#print-width
args: ["--print-width=120"]
args: ["--print-width=140"]
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
# Docker: Python-OpenCV-FFmpeg(-CUDA)

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.
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.

## Tags

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

## Build

Expand Down
62 changes: 21 additions & 41 deletions cpu/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -18,35 +18,26 @@ ENV DEBIAN_FRONTEND=noninteractive \


RUN \
# add sources for older pythons
apt-get update -q --fix-missing && \
apt-get install -y --no-install-recommends software-properties-common && \
if [[ "$PYTHON_VERSION" =~ ^(2.7|3.6|3.7|3.12)$ ]]; then \
add-apt-repository ppa:deadsnakes/ppa ; \
fi && \
apt-get update -qq --fix-missing && \
apt-get install -y --no-install-recommends \
software-properties-common \
dirmngr \
gnupg && \
add-apt-repository ppa:deadsnakes/ppa && \
apt-add-repository universe && \
apt-get -y update -qq --fix-missing && \
apt-get -y install --no-install-recommends \
python${PYTHON_VERSION} \
python${PYTHON_VERSION}-dev \
$( [ ${PYTHON_VERSION%%.*} -ge 3 ] && echo "python${PYTHON_VERSION}-distutils" ) \
$( if [ "${PYTHON_VERSION%%.*}" -eq 3 ] && [ "${PYTHON_VERSION#*.}" -lt 10 ]; then echo "python${PYTHON_VERSION}-distutils"; fi ) \
curl \
wget \
&& \
wget && \
rm -rf /var/lib/apt/lists/* && \

# Set the default python and install PIP packages
update-alternatives --install /usr/bin/python${PYTHON_VERSION%%.*} python${PYTHON_VERSION%%.*} /usr/bin/python${PYTHON_VERSION} 1 && \
update-alternatives --install /usr/bin/python python /usr/bin/python${PYTHON_VERSION} 1 && \

# install python dependencies
# sysctl -w net.ipv4.ip_forward=1 ; \
if [[ "$PYTHON_VERSION" == "2.7" || "$PYTHON_VERSION" == "3.6" || "$PYTHON_VERSION" == "3.7" ]]; then \
PIP_URL="https://bootstrap.pypa.io/pip/$PYTHON_VERSION/get-pip.py" ; \
else \
apt-get -y install --no-install-recommends python${PYTHON_VERSION}-distutils ; \
PIP_URL="https://bootstrap.pypa.io/get-pip.py" ; \
fi && \
# install python dependencies \
PIP_URL="https://bootstrap.pypa.io/get-pip.py" && \
curl $PIP_URL | python

ENV PYTHONPATH="/usr/lib/python${PYTHON_VERSION}/site-packages:/usr/local/lib/python${PYTHON_VERSION}/site-packages"
Expand All @@ -58,15 +49,12 @@ RUN \
unzip \
cmake \
ffmpeg \
$( [ "$UBUNTU_VERSION" = "20.04" ] && libtbb2 || libtbb12 ) \
gfortran \
apt-utils \
pkg-config \
checkinstall \
qtbase5-dev qt5-qmake \
build-essential \
libopenblas-base \
libopenblas-dev \
liblapack-dev \
libatlas-base-dev \
libavcodec-dev \
Expand All @@ -89,21 +77,18 @@ RUN \
zlib1g-dev \
libsm6 \
libxext6 \
libxrender1 \
&& \
libxrender1 && \
pip install numpy && \

# Install OpenCV
# Install OpenCV
wget https://github.com/opencv/opencv/archive/${OPENCV_VERSION}.zip -O opencv.zip --progress=bar:force:noscroll --no-check-certificate && \
unzip -q opencv.zip && \
mv /opencv-${OPENCV_VERSION} /opencv && \
mv opencv-${OPENCV_VERSION} /opencv && \
rm opencv.zip && \
wget https://github.com/opencv/opencv_contrib/archive/${OPENCV_VERSION}.zip -O opencv_contrib.zip --progress=bar:force:noscroll --no-check-certificate && \
unzip -q opencv_contrib.zip && \
mv /opencv_contrib-${OPENCV_VERSION} /opencv_contrib && \
mv opencv_contrib-${OPENCV_VERSION} /opencv_contrib && \
rm opencv_contrib.zip && \

# Prepare build
# Prepare build
mkdir /opencv/build && \
cd /opencv/build && \
cmake \
Expand All @@ -114,8 +99,8 @@ RUN \
-D BUILD_TESTS=OFF \
-D CMAKE_INSTALL_PREFIX=/usr/local \
-D OPENCV_EXTRA_MODULES_PATH=/opencv_contrib/modules \
-D BUILD_opencv_python3=$( [ ${PYTHON_VERSION%%.*} -ge 3 ] && echo "ON" || echo "OFF" ) \
-D BUILD_opencv_python2=$( [ ${PYTHON_VERSION%%.*} -lt 3 ] && echo "ON" || echo "OFF" ) \
-D BUILD_opencv_python3=ON \
-D BUILD_opencv_python2=OFF \
-D PYTHON${PYTHON_VERSION%%.*}_EXECUTABLE=$(which python${PYTHON_VERSION}) \
-D PYTHON_DEFAULT_EXECUTABLE=$(which python${PYTHON_VERSION}) \
-D BUILD_EXAMPLES=OFF \
Expand All @@ -130,16 +115,13 @@ RUN \
-D WITH_LAPACK=ON \
#-D WITH_HPX=ON \
-D ENABLE_PRECOMPILED_HEADERS=OFF \
.. \
&& \

# Build, Test and Install
.. && \
# Build, Test and Install
cd /opencv/build && \
make -j$(nproc) && \
make install && \
ldconfig && \

# cleaning
# cleaning
apt-get -y remove \
unzip \
cmake \
Expand All @@ -148,7 +130,6 @@ RUN \
pkg-config \
checkinstall \
build-essential \
libopenblas-dev \
liblapack-dev \
libatlas-base-dev \
libavcodec-dev \
Expand All @@ -165,8 +146,7 @@ RUN \
libglew-dev \
libpostproc-dev \
libeigen3-dev \
zlib1g-dev \
&& \
zlib1g-dev && \
apt-get autoremove -y && \
apt-get clean && \
rm -rf /opencv /opencv_contrib /var/lib/apt/lists/*
Expand Down
50 changes: 16 additions & 34 deletions gpu/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -24,35 +24,26 @@ ENV DEBIAN_FRONTEND=noninteractive \
# ENV LD_LIBRARY_PATH /usr/local/${CUDA}/compat:$LD_LIBRARY_PATH

RUN \
# add sources for older pythons
apt-get update -qq --fix-missing && \
apt-get install -y --no-install-recommends software-properties-common && \
if [[ "$PYTHON_VERSION" =~ ^(2.7|3.6|3.7|3.12)$ ]]; then \
add-apt-repository ppa:deadsnakes/ppa ; \
fi && \
apt-get install -y --no-install-recommends \
software-properties-common \
dirmngr \
gnupg && \
add-apt-repository ppa:deadsnakes/ppa && \
apt-add-repository universe && \
apt-get -y update -qq --fix-missing && \
apt-get -y install --no-install-recommends \
python${PYTHON_VERSION} \
python${PYTHON_VERSION}-dev \
$( [ ${PYTHON_VERSION%%.*} -ge 3 ] && echo "python${PYTHON_VERSION}-distutils" ) \
$( if [ "${PYTHON_VERSION%%.*}" -eq 3 ] && [ "${PYTHON_VERSION#*.}" -lt 10 ]; then echo "python${PYTHON_VERSION}-distutils"; fi ) \
curl \
wget \
&& \
wget && \
rm -rf /var/lib/apt/lists/* && \

# Set the default python and install PIP packages
update-alternatives --install /usr/bin/python${PYTHON_VERSION%%.*} python${PYTHON_VERSION%%.*} /usr/bin/python${PYTHON_VERSION} 1 && \
update-alternatives --install /usr/bin/python python /usr/bin/python${PYTHON_VERSION} 1 && \

# install python dependencies
# sysctl -w net.ipv4.ip_forward=1 ; \
if [[ "$PYTHON_VERSION" == "2.7" || "$PYTHON_VERSION" == "3.6" || "$PYTHON_VERSION" == "3.7" ]]; then \
PIP_URL="https://bootstrap.pypa.io/pip/$PYTHON_VERSION/get-pip.py" ; \
else \
apt-get -y install --no-install-recommends python${PYTHON_VERSION}-distutils ; \
PIP_URL="https://bootstrap.pypa.io/get-pip.py" ; \
fi && \
PIP_URL="https://bootstrap.pypa.io/get-pip.py" && \
curl $PIP_URL | python

ENV PYTHONPATH="/usr/lib/python${PYTHON_VERSION}/site-packages:/usr/local/lib/python${PYTHON_VERSION}/site-packages"
Expand All @@ -63,22 +54,18 @@ RUN \
CUDA=`basename $CUDA_PATH` && \
echo "$CUDA_PATH/compat" >> /etc/ld.so.conf.d/${CUDA/./-}.conf && \
ldconfig && \

# Install all dependencies for OpenCV
# Install all dependencies for OpenCV
apt-get -y update -qq --fix-missing && \
apt-get -y install --no-install-recommends \
unzip \
cmake \
ffmpeg \
$( [ "$UBUNTU_VERSION" = "20.04" ] && libtbb2 || libtbb12 ) \
gfortran \
apt-utils \
pkg-config \
checkinstall \
qtbase5-dev qt5-qmake \
build-essential \
libopenblas-base \
libopenblas-dev \
liblapack-dev \
libatlas-base-dev \
libavcodec-dev \
Expand All @@ -104,8 +91,7 @@ RUN \
libxrender1 \
&& \
pip install numpy && \

# Install OpenCV
# Install OpenCV
wget https://github.com/opencv/opencv/archive/$OPENCV_VERSION.zip -O opencv.zip --progress=bar:force:noscroll && \
unzip -q opencv.zip && \
mv /opencv-$OPENCV_VERSION /opencv && \
Expand All @@ -114,8 +100,7 @@ RUN \
unzip -q opencv_contrib.zip && \
mv /opencv_contrib-$OPENCV_VERSION /opencv_contrib && \
rm opencv_contrib.zip && \

# Prepare build
# Prepare build
mkdir /opencv/build && \
cd /opencv/build && \
cmake \
Expand All @@ -126,8 +111,8 @@ RUN \
-D BUILD_TESTS=OFF \
-D CMAKE_INSTALL_PREFIX=/usr/local \
-D OPENCV_EXTRA_MODULES_PATH=/opencv_contrib/modules \
-D BUILD_opencv_python3=$( [ ${PYTHON_VERSION%%.*} -ge 3 ] && echo "ON" || echo "OFF" ) \
-D BUILD_opencv_python2=$( [ ${PYTHON_VERSION%%.*} -lt 3 ] && echo "ON" || echo "OFF" ) \
-D BUILD_opencv_python3=ON \
-D BUILD_opencv_python2=OFF \
-D PYTHON${PYTHON_VERSION%%.*}_EXECUTABLE=$(which python${PYTHON_VERSION}) \
-D PYTHON_DEFAULT_EXECUTABLE=$(which python${PYTHON_VERSION}) \
-D BUILD_EXAMPLES=OFF \
Expand All @@ -148,21 +133,19 @@ RUN \
# https://stackoverflow.com/questions/28010399/build-opencv-with-cuda-support
-D CUDA_ARCH_BIN="5.3 6.1 7.0 7.5" \
-D CUDA_ARCH_PTX="" \
-D WITH_CUBLAS=ON \
#-D WITH_CUBLAS=ON \
-D WITH_NVCUVID=ON \
-D ENABLE_FAST_MATH=1 \
-D CUDA_FAST_MATH=1 \
-D ENABLE_PRECOMPILED_HEADERS=OFF \
.. \
&& \

# Build, Test and Install
# Build, Test and Install
cd /opencv/build && \
make -j$(nproc) && \
make install && \
ldconfig && \

# cleaning
# cleaning
apt-get -y remove \
unzip \
cmake \
Expand All @@ -171,7 +154,6 @@ RUN \
pkg-config \
checkinstall \
build-essential \
libopenblas-dev \
liblapack-dev \
libatlas-base-dev \
libavcodec-dev \
Expand Down
Loading