diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md index 15cdcc8..7d8e918 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.md +++ b/.github/ISSUE_TEMPLATE/bug_report.md @@ -15,8 +15,8 @@ assignees: '' Steps to reproduce the behavior: 1. Go to '...' -1. Run '....' -1. See error +2. Run '....' +3. See error diff --git a/.github/workflows/docker-builds.yml b/.github/workflows/docker-builds.yml index 6e8ed18..4103fa7 100644 --- a/.github/workflows/docker-builds.yml +++ b/.github/workflows/docker-builds.yml @@ -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 diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index e3f343b..36d301d 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,3 +1,6 @@ +default_language_version: + python: python3 + ci: autofix_prs: true autoupdate_commit_msg: "[pre-commit.ci] pre-commit suggestions" @@ -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 @@ -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"] diff --git a/README.md b/README.md index 4a09b32..d59fa75 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/cpu/Dockerfile b/cpu/Dockerfile index 3ae91fd..ca8891f 100644 --- a/cpu/Dockerfile +++ b/cpu/Dockerfile @@ -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" @@ -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 \ @@ -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 \ @@ -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 \ @@ -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 \ @@ -148,7 +130,6 @@ RUN \ pkg-config \ checkinstall \ build-essential \ - libopenblas-dev \ liblapack-dev \ libatlas-base-dev \ libavcodec-dev \ @@ -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/* diff --git a/gpu/Dockerfile b/gpu/Dockerfile index 6243e78..43e329e 100644 --- a/gpu/Dockerfile +++ b/gpu/Dockerfile @@ -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" @@ -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 \ @@ -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 && \ @@ -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 \ @@ -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 \ @@ -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 \ @@ -171,7 +154,6 @@ RUN \ pkg-config \ checkinstall \ build-essential \ - libopenblas-dev \ liblapack-dev \ libatlas-base-dev \ libavcodec-dev \