From 3e54d58a747d4268d89e0f459654e078e5d755c3 Mon Sep 17 00:00:00 2001 From: deadprogram Date: Fri, 21 Jul 2023 16:44:15 +0200 Subject: [PATCH] docker: remove CUDA 10 and add CUDA 12 Signed-off-by: deadprogram --- .github/workflows/docker.yml | 44 +++++++++--------- Dockerfile.opencv-gpu-cuda-11 | 4 +- Dockerfile.opencv-gpu-cuda-11.2.2 | 2 +- Dockerfile.opencv-gpu-cuda-12 | 74 +++++++++++++++++++++++++++++++ 4 files changed, 99 insertions(+), 25 deletions(-) create mode 100644 Dockerfile.opencv-gpu-cuda-12 diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index 4cf9b06b..b308d0e3 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -60,8 +60,8 @@ jobs: cache-from: type=gha cache-to: type=gha,mode=max - opencv-gpu-cuda-10: - name: opencv-gpu-cuda-10 + opencv-gpu-cuda-11: + name: opencv-gpu-cuda-11 runs-on: ubuntu-latest permissions: packages: write @@ -76,8 +76,8 @@ jobs: uses: docker/metadata-action@v4 with: images: | - gocv/opencv:4.8.0-gpu-cuda-10 - ghcr.io/${{ github.repository_owner }}/opencv:4.8.0-gpu-cuda-10 + gocv/4.8.0-gpu-cuda-11 + ghcr.io/${{ github.repository_owner }}/4.8.0-gpu-cuda-11 tags: | type=sha,format=long type=raw,value=latest @@ -95,19 +95,19 @@ jobs: - name: Build and push uses: docker/build-push-action@v4 with: - file: Dockerfile.opencv-gpu-cuda-10 + file: Dockerfile.opencv-gpu-cuda-11 platforms: linux/amd64 context: . push: true tags: | - gocv/opencv:4.8.0-gpu-cuda-10 - ghcr.io/${{ github.repository_owner }}/opencv:4.8.0-gpu-cuda-10 + gocv/opencv:4.8.0-gpu-cuda-11 + ghcr.io/${{ github.repository_owner }}/opencv:4.8.0-gpu-cuda-11 labels: ${{ steps.meta.outputs.labels }} cache-from: type=gha cache-to: type=gha,mode=max - opencv-gpu-cuda-11: - name: opencv-gpu-cuda-11 + opencv-gpu-cuda-11-2-2: + name: opencv-gpu-cuda-11-2-2 runs-on: ubuntu-latest permissions: packages: write @@ -122,8 +122,8 @@ jobs: uses: docker/metadata-action@v4 with: images: | - gocv/4.8.0-gpu-cuda-11 - ghcr.io/${{ github.repository_owner }}/4.8.0-gpu-cuda-11 + gocv/opencv:4.8.0-gpu-cuda-11.2.2 + ghcr.io/${{ github.repository_owner }}/opencv:4.8.0-gpu-cuda-11.2.2 tags: | type=sha,format=long type=raw,value=latest @@ -141,19 +141,19 @@ jobs: - name: Build and push uses: docker/build-push-action@v4 with: - file: Dockerfile.opencv-gpu-cuda-11 + file: Dockerfile.opencv-gpu-cuda-11.2.2 platforms: linux/amd64 context: . push: true tags: | - gocv/opencv:4.8.0-gpu-cuda-11 - ghcr.io/${{ github.repository_owner }}/opencv:4.8.0-gpu-cuda-11 + gocv/opencv:4.8.0-gpu-cuda-11.2.2 + ghcr.io/${{ github.repository_owner }}/opencv:4.8.0-gpu-cuda-11.2.2 labels: ${{ steps.meta.outputs.labels }} cache-from: type=gha cache-to: type=gha,mode=max - opencv-gpu-cuda-11-2-2: - name: opencv-gpu-cuda-11-2-2 + opencv-gpu-cuda-12: + name: opencv-gpu-cuda-12 runs-on: ubuntu-latest permissions: packages: write @@ -168,8 +168,8 @@ jobs: uses: docker/metadata-action@v4 with: images: | - gocv/opencv:4.8.0-gpu-cuda-11.2.2 - ghcr.io/${{ github.repository_owner }}/opencv:4.8.0-gpu-cuda-11.2.2 + gocv/4.8.0-gpu-cuda-12 + ghcr.io/${{ github.repository_owner }}/4.8.0-gpu-cuda-12 tags: | type=sha,format=long type=raw,value=latest @@ -187,17 +187,17 @@ jobs: - name: Build and push uses: docker/build-push-action@v4 with: - file: Dockerfile.opencv-gpu-cuda-11.2.2 + file: Dockerfile.opencv-gpu-cuda-12 platforms: linux/amd64 context: . push: true tags: | - gocv/opencv:4.8.0-gpu-cuda-11.2.2 - ghcr.io/${{ github.repository_owner }}/opencv:4.8.0-gpu-cuda-11.2.2 + gocv/opencv:4.8.0-gpu-cuda-12 + ghcr.io/${{ github.repository_owner }}/opencv:4.8.0-gpu-cuda-12 labels: ${{ steps.meta.outputs.labels }} cache-from: type=gha cache-to: type=gha,mode=max - + opencv-ubuntu-18-04: name: opencv-ubuntu-18-04 runs-on: ubuntu-latest diff --git a/Dockerfile.opencv-gpu-cuda-11 b/Dockerfile.opencv-gpu-cuda-11 index c7c5f109..eb32de23 100644 --- a/Dockerfile.opencv-gpu-cuda-11 +++ b/Dockerfile.opencv-gpu-cuda-11 @@ -1,7 +1,7 @@ # to build this docker image: # docker build -f Dockerfile.opencv-gpu-cuda-11 -t ghcr.io/hybridgroup/opencv:4.8.0-gpu-cuda-11 . # docker build --build-arg OPENCV_VERSION="4.x" --build-arg OPENCV_FILE="https://github.com/opencv/opencv/archive/refs/heads/4.x.zip" --build-arg OPENCV_CONTRIB_FILE="https://github.com/opencv/opencv_contrib/archive/refs/heads/4.x.zip" -f Dockerfile.opencv-gpu-cuda-11.2.2 -t ghcr.io/hybridgroup/opencv:4.8.0-dev-gpu-cuda-11 . -FROM nvidia/cuda:11.5.2-cudnn8-devel-ubuntu20.04 AS opencv-gpu-cuda-11-base +FROM nvidia/cuda:11.8.0-cudnn8-devel-ubuntu20.04 AS opencv-gpu-cuda-11-base LABEL maintainer="hybridgroup" ENV DEBIAN_FRONTEND=noninteractive @@ -65,7 +65,7 @@ RUN curl -Lo opencv.zip ${OPENCV_FILE} && \ # install golang here FROM opencv-gpu-cuda-11-base AS opencv-gpu-cuda-11-golang -ENV GO_RELEASE=1.20.2 +ENV GO_RELEASE=1.20.6 RUN wget https://dl.google.com/go/go${GO_RELEASE}.linux-amd64.tar.gz && \ tar xfv go${GO_RELEASE}.linux-amd64.tar.gz -C /usr/local && \ rm go${GO_RELEASE}.linux-amd64.tar.gz diff --git a/Dockerfile.opencv-gpu-cuda-11.2.2 b/Dockerfile.opencv-gpu-cuda-11.2.2 index 7a57cc6d..4f25070f 100644 --- a/Dockerfile.opencv-gpu-cuda-11.2.2 +++ b/Dockerfile.opencv-gpu-cuda-11.2.2 @@ -65,7 +65,7 @@ RUN curl -Lo opencv.zip ${OPENCV_FILE} && \ # install golang here FROM opencv-gpu-cuda-11-base AS opencv-gpu-cuda-11-golang -ENV GO_RELEASE=1.20.2 +ENV GO_RELEASE=1.20.6 RUN wget https://dl.google.com/go/go${GO_RELEASE}.linux-amd64.tar.gz && \ tar xfv go${GO_RELEASE}.linux-amd64.tar.gz -C /usr/local && \ rm go${GO_RELEASE}.linux-amd64.tar.gz diff --git a/Dockerfile.opencv-gpu-cuda-12 b/Dockerfile.opencv-gpu-cuda-12 new file mode 100644 index 00000000..8c9722b3 --- /dev/null +++ b/Dockerfile.opencv-gpu-cuda-12 @@ -0,0 +1,74 @@ +# to build this docker image: +# docker build -f Dockerfile.opencv-gpu-cuda-12 -t ghcr.io/hybridgroup/opencv:4.8.0-gpu-cuda-12 . +# docker build --build-arg OPENCV_VERSION="4.x" --build-arg OPENCV_FILE="https://github.com/opencv/opencv/archive/refs/heads/4.x.zip" --build-arg OPENCV_CONTRIB_FILE="https://github.com/opencv/opencv_contrib/archive/refs/heads/4.x.zip" -f Dockerfile.opencv-gpu-cuda-12 -t ghcr.io/hybridgroup/opencv:4.8.0-dev-gpu-cuda-12 . +FROM nvidia/cuda:12.1.0-cudnn8-devel-ubuntu22.04 AS opencv-gpu-cuda-12-base +LABEL maintainer="hybridgroup" +ENV DEBIAN_FRONTEND=noninteractive + +RUN apt-get update && apt-get install -y --no-install-recommends \ + git build-essential cmake pkg-config unzip libgtk2.0-dev \ + wget curl ca-certificates libcurl4-openssl-dev libssl-dev \ + libavcodec-dev libavformat-dev libswscale-dev libtbb2 libtbb-dev \ + libjpeg-turbo8-dev libpng-dev libtiff-dev libdc1394-dev nasm && \ + rm -rf /var/lib/apt/lists/* + +ARG OPENCV_VERSION="4.8.0" +ENV OPENCV_VERSION $OPENCV_VERSION + +ARG OPENCV_FILE="https://github.com/opencv/opencv/archive/${OPENCV_VERSION}.zip" +ENV OPENCV_FILE $OPENCV_FILE + +ARG OPENCV_CONTRIB_FILE="https://github.com/opencv/opencv_contrib/archive/${OPENCV_VERSION}.zip" +ENV OPENCV_CONTRIB_FILE $OPENCV_CONTRIB_FILE + +RUN curl -Lo opencv.zip ${OPENCV_FILE} && \ + unzip -q opencv.zip && \ + curl -Lo opencv_contrib.zip ${OPENCV_CONTRIB_FILE} && \ + unzip -q opencv_contrib.zip && \ + rm opencv.zip opencv_contrib.zip && \ + cd opencv-${OPENCV_VERSION} && \ + mkdir build && cd build && \ + cmake -D CMAKE_BUILD_TYPE=RELEASE \ + -D WITH_IPP=OFF \ + -D WITH_OPENGL=OFF \ + -D WITH_QT=OFF \ + -D CMAKE_INSTALL_PREFIX=/usr/local \ + -D OPENCV_EXTRA_MODULES_PATH=../../opencv_contrib-${OPENCV_VERSION}/modules \ + -D OPENCV_ENABLE_NONFREE=ON \ + -D WITH_JASPER=OFF \ + -D BUILD_DOCS=OFF \ + -D BUILD_EXAMPLES=OFF \ + -D BUILD_TESTS=OFF \ + -D BUILD_PERF_TESTS=ON \ + -D BUILD_opencv_java=NO \ + -D BUILD_opencv_python=NO \ + -D BUILD_opencv_python2=NO \ + -D BUILD_opencv_python3=NO \ + -D WITH_TBB=ON \ + -D BUILD_JPEG=ON \ + -D WITH_SIMD=ON \ + -D WITH_LIBJPEG_TURBO_SIMD=ON \ + -D WITH_CUDA=ON \ + -D ENABLE_FAST_MATH=1 \ + -D CUDA_FAST_MATH=1 \ + -D WITH_CUBLAS=1 \ + -D CUDA_TOOLKIT_ROOT_DIR=/usr/local/cuda/ \ + -D BUILD_opencv_cudacodec=OFF \ + -D WITH_CUDNN=ON \ + -D OPENCV_DNN_CUDA=ON \ + -D CUDA_GENERATION=Auto \ + -D OPENCV_GENERATE_PKGCONFIG=ON .. && \ + make -j $(nproc --all) && \ + make preinstall && make install && ldconfig && \ + cd / && rm -rf opencv* + +# install golang here +FROM opencv-gpu-cuda-12-base AS opencv-gpu-cuda-12-golang + +ENV GO_RELEASE=1.20.6 +RUN wget https://dl.google.com/go/go${GO_RELEASE}.linux-amd64.tar.gz && \ + tar xfv go${GO_RELEASE}.linux-amd64.tar.gz -C /usr/local && \ + rm go${GO_RELEASE}.linux-amd64.tar.gz +ENV PATH="${PATH}:/usr/local/go/bin" + +CMD ["go version"]