Skip to content

⬆️🚩🦺🐛 media-libs/opencv: add 4.10.0#37479

Open
Jamim wants to merge 3 commits intogentoo:masterfrom
Jamim:media-libs/opencv
Open

⬆️🚩🦺🐛 media-libs/opencv: add 4.10.0#37479
Jamim wants to merge 3 commits intogentoo:masterfrom
Jamim:media-libs/opencv

Conversation

@Jamim
Copy link
Copy Markdown
Contributor

@Jamim Jamim commented Jul 8, 2024

Hello everyone,

OpenCV 4.10.0 was released in early June.
It would be nice to finaly have it in the Portage tree.

Changelog:

Changes in comparison to 4.9.0-r2:

  • 🚩 add the avif USE flag
  • 🦺 add CUDA host compiler validation
  • update tesseract requirement (930368)
  • remove unnecessary restrictions
  • 🐛 fix

These changes also:

  • add changelog and doc urls to metadata.xml
  • add the video USE flag to acct-user/portage

Based on:

diff -u opencv-4.{9.0-r2,10.0}.ebuild

--- opencv-4.9.0-r2.ebuild	2024-11-02 03:52:01.524457925 +0300
+++ opencv-4.10.0.ebuild	2024-11-02 03:52:07.296453059 +0300
@@ -56,7 +56,7 @@
 			https://github.com/${PN}/${PN}_extra/archive/refs/tags/${PV}.tar.gz -> ${PN}_extra-${PV}.tar.gz
 		)
 	"
-	KEYWORDS="amd64 ~arm arm64 ~loong ~ppc ~ppc64 ~riscv x86"
+	KEYWORDS="~amd64 ~arm ~arm64 ~loong ~ppc ~ppc64 ~riscv ~x86"
 fi
 
 LICENSE="Apache-2.0"
@@ -72,7 +72,7 @@
 # video
 IUSE+=" +ffmpeg gstreamer xine vaapi v4l gphoto2 ieee1394"
 # image
-IUSE+=" gdal jasper jpeg jpeg2k openexr png quirc tesseract tiff webp"
+IUSE+=" avif gdal jasper jpeg jpeg2k openexr png quirc tesseract tiff webp"
 # gui
 IUSE+=" gtk3 qt5 qt6 opengl vtk"
 # parallel
@@ -111,10 +111,7 @@
 	amd64? ( cpu_flags_x86_sse cpu_flags_x86_sse2 )
 	cpu_flags_x86_avx2? ( cpu_flags_x86_f16c )
 	cpu_flags_x86_f16c? ( cpu_flags_x86_avx )
-	cuda? (
-		contrib
-		tesseract? ( opencl )
-	)
+	cuda? ( contrib	)
 	cudnn? ( cuda )
 	dnnsamples? ( examples )
 	gflags? ( contrib )
@@ -134,18 +131,14 @@
 	test? ( || ( ffmpeg gstreamer ) jpeg png tiff features2d  )
 "
 
-# TODO find a way to compile these with the cuda compiler
-REQUIRED_USE+="
-	cuda? ( !gdal !openexr !tbb )
-"
-
 RESTRICT="!test? ( test )"
 
 COMMON_DEPEND="
+	avif? ( media-libs/libavif:=[${MULTILIB_USEDEP}] )
 	app-arch/bzip2[${MULTILIB_USEDEP}]
 	dev-libs/protobuf:=[${MULTILIB_USEDEP}]
 	sys-libs/zlib[${MULTILIB_USEDEP}]
-	cuda? ( <dev-util/nvidia-cuda-toolkit-12.4:0= )
+	cuda? ( dev-util/nvidia-cuda-toolkit:= )
 	cudnn? ( dev-libs/cudnn:= )
 	contribdnn? ( dev-libs/flatbuffers:= )
 	contribhdf? ( sci-libs/hdf5:= )
@@ -171,7 +164,6 @@
 		media-libs/libdc1394:=[${MULTILIB_USEDEP}]
 		sys-libs/libraw1394[${MULTILIB_USEDEP}]
 	)
-	java? ( >=virtual/jre-1.8:* )
 	jpeg? ( media-libs/libjpeg-turbo:=[${MULTILIB_USEDEP}] )
 	jpeg2k? (
 		jasper? ( media-libs/jasper:= )
@@ -218,7 +210,7 @@
 		)
 	)
 	quirc? ( media-libs/quirc )
-	tesseract? ( app-text/tesseract[opencl=,${MULTILIB_USEDEP}] )
+	tesseract? ( app-text/tesseract[${MULTILIB_USEDEP}] )
 	tbb? ( dev-cpp/tbb:=[${MULTILIB_USEDEP}] )
 	tiff? ( media-libs/tiff:=[${MULTILIB_USEDEP}] )
 	v4l? ( >=media-libs/libv4l-0.8.3[${MULTILIB_USEDEP}] )
@@ -235,6 +227,7 @@
 # TODO gstreamer dependencies
 DEPEND+="
 	test? (
+		cuda? ( acct-user/portage[video] )
 		gstreamer? (
 			media-plugins/gst-plugins-jpeg[${MULTILIB_USEDEP}]
 			media-plugins/gst-plugins-x264[${MULTILIB_USEDEP}]
@@ -269,61 +262,75 @@
 	"${FILESDIR}/${PN}-4.9.0-drop-python2-detection.patch"
 	"${FILESDIR}/${PN}-4.9.0-ade-0.1.2d.tar.gz.patch"
 	"${FILESDIR}/${PN}-4.9.0-cmake-cleanup.patch"
+	"${FILESDIR}"/${P}-cuda-fp16.patch
+	"${FILESDIR}"/${P}-cudnn-9.patch
 
 	# TODO applied in src_prepare
 	# "${FILESDIR}/${PN}_contrib-${PV}-rgbd.patch"
 	# "${FILESDIR}/${PN}_contrib-4.8.1-NVIDIAOpticalFlowSDK-2.0.tar.gz.patch"
 )
 
-cuda_get_cuda_compiler() {
-	local compiler
-	tc-is-gcc && compiler="gcc"
-	tc-is-clang && compiler="clang"
-	[[ -z "$compiler" ]] && die "no compiler specified"
-
-	local package="sys-devel/${compiler}"
-	local version="${package}"
-	local CUDAHOSTCXX_test
-	while
-		local CUDAHOSTCXX="${CUDAHOSTCXX_test}"
+cuda_get_host_compiler() {
+	local compiler=$(tc-get-compiler-type)
+	if ! (tc-is-gcc || tc-is-clang); then
+		die "${compiler} compiler is not supported"
+	fi
+	local default_compiler="${compiler}-$(${compiler}-major-version)"
+	local version="sys-devel/${compiler}"
+
+	# try the default compiler first
+	local NVCC_CCBIN=${default_compiler}
+	while ! echo "int main(){}" | nvcc -ccbin "${NVCC_CCBIN}" - -x cu &>/dev/null; do
 		version=$(best_version "${version}")
 		if [[ -z "${version}" ]]; then
-			if [[ -z "${CUDAHOSTCXX}" ]]; then
-				die "could not find supported version of ${package}"
-			fi
-			break
+			die "could not find a supported version of ${compiler}"
 		fi
-		CUDAHOSTCXX_test="$(
-			dirname "$(
-				realpath "$(
-					which "${compiler}-$(echo "${version}" | grep -oP "(?<=${package}-)[0-9]*")"
-				)"
-			)"
-		)"
 		version="<${version}"
-	do ! echo "int main(){}" | nvcc "-ccbin ${CUDAHOSTCXX_test}" - -x cu &>/dev/null; done
 
-	echo "${CUDAHOSTCXX}"
+		# nvcc accepts just an executable name, too.
+		# search for NVCC_CCBIN here:
+		# https://docs.nvidia.com/cuda/cuda-compiler-driver-nvcc/
+		NVCC_CCBIN="$(echo "${version}" | sed 's:.*/\([a-z]*-[0-9]*\).*:\1:')"
+	done
+
+	if [ ${NVCC_CCBIN} != ${default_compiler} ]; then
+		ewarn "The default compiler, ${default_compiler} is not supported by nvcc!"
+		ewarn "Compiler version mismatch causes undefined reference errors on linking, so"
+		ewarn "${NVCC_CCBIN}, which is supported by nvcc, will be used to compile OpenCV."
+	fi
+
+	echo "${NVCC_CCBIN}"
 }
 
 cuda_get_host_native_arch() {
-	: "${CUDAARCHS:=$(__nvcc_device_query)}"
-	echo "${CUDAARCHS}"
+	# __nvcc_device_query might fail sporadically,
+	# so a retry is needed for safety
+	local native_arch="$(__nvcc_device_query || __nvcc_device_query)"
+	if [[ -z "${native_arch}" ]]; then
+		ewarn "Failed to get host's native CUDA architecture!"
+		ewarn "CUDA_ARCH_BIN might be miscalculated by OpenCV's CMake scripts,"
+		ewarn "so to be safe, set CUDAARCHS or CUDA_ARCH_BIN in your make.conf."
+	fi
+	echo "${native_arch}"
 }
 
 pkg_pretend() {
-	if use cuda && [[ -z "${CUDA_GENERATION}" ]] && [[ -z "${CUDA_ARCH_BIN}" ]]; then # TODO CUDAARCHS
-		einfo "The target CUDA architecture can be set via one of:"
-		einfo "  - CUDA_GENERATION set to one of Maxwell, Pascal, Volta, Turing, Ampere, Lovelace, Hopper, Auto"
-		einfo "  - CUDA_ARCH_BIN, (and optionally CUDA_ARCH_PTX) in the form of x.y tuples."
-		einfo "      You can specify multiple tuple separated by \";\"."
+	if use cuda && [[ -z "${CUDAARCHS}" ]] && [[ -z "${CUDA_GENERATION}" ]] && [[ -z "${CUDA_ARCH_BIN}" ]]; then
+		einfo "The target CUDA architecture can be set via one of these variables in make.conf:"
+		einfo "  - CUDAARCHS (prefered)"
+		einfo "    https://cmake.org/cmake/help/latest/envvar/CUDAARCHS.html"
+		einfo "      a semicolon-separated list of architectures, e.g. \"35;50;72\","
+		einfo "      as described in https://cmake.org/cmake/help/latest/prop_tgt/CUDA_ARCHITECTURES.html"
+		einfo "  - CUDA_ARCH_BIN (and optionally CUDA_ARCH_PTX)"
+		einfo "    https://docs.opencv.org/4.x/db/d05/tutorial_config_reference.html#autotoc_md898"
+		einfo "      a semicolon-separated list of architectures, e.g. \"3.5;5.0;7.2\""
+		einfo "  - CUDA_GENERATION (NOT recommended, might cause miscalculation):"
+		einfo "    https://docs.opencv.org/4.x/db/d05/tutorial_config_reference.html#autotoc_md898"
+		einfo "      one of Maxwell, Pascal, Volta, Turing, Ampere, Lovelace, Hopper, Auto"
 		einfo ""
 		einfo "The CUDA architecture tuple for your device can be found at https://developer.nvidia.com/cuda-gpus."
-	fi
-
-	if use cuda && [[ ${MERGE_TYPE} == "buildonly" ]] && [[ -n "${CUDA_GENERATION}" || -n "${CUDA_ARCH_BIN}" ]]; then
-		local info_message="When building a binary package it's recommended to unset CUDA_GENERATION and CUDA_ARCH_BIN"
-		einfo "$info_message so all available architectures are build."
+		einfo ""
+		einfo "Since none of them are set, CUDAARCHS will be calculated automatically."
 	fi
 
 	[[ ${MERGE_TYPE} != binary ]] && use openmp && tc-check-openmp
@@ -346,10 +353,6 @@
 		cd "${WORKDIR}/${PN}_contrib-${PV}" || die
 		eapply "${FILESDIR}/${PN}_contrib-4.8.1-rgbd.patch"
 		eapply "${FILESDIR}/${PN}_contrib-4.8.1-NVIDIAOpticalFlowSDK-2.0.tar.gz.patch"
-		if has_version ">=dev-util/nvidia-cuda-toolkit-12.4" && use cuda; then
-			# TODO https://github.com/NVIDIA/cccl/pull/1522
-			eapply "${FILESDIR}/${PN}_contrib-4.9.0-cuda-12.4.patch"
-		fi
 		cd "${S}" || die
 
 		! use contribcvv && { rm -R "${WORKDIR}/${PN}_contrib-${PV}/modules/cvv" || die; }
@@ -456,12 +459,13 @@
 
 	# Optional 3rd party components
 	# ===================================================
-		-DENABLE_DOWNLOAD=yes
+		-DENABLE_DOWNLOAD=no
 		-DOPENCV_ENABLE_NONFREE="$(usex non-free)"
 		-DWITH_QUIRC="$(usex quirc)"
 		-DWITH_FLATBUFFERS="$(multilib_native_usex contribdnn)"
 		-DWITH_1394="$(usex ieee1394)"
 		# -DWITH_AVFOUNDATION="no" # IOS
+		-DWITH_AVIF=$(usex avif)
 		-DWITH_VTK="$(multilib_native_usex vtk)"
 		-DWITH_EIGEN="$(usex eigen)"
 		-DWITH_VFW="no" # Video windows support
@@ -511,7 +515,8 @@
 		-DWITH_GDAL="$(multilib_native_usex gdal)"
 		-DWITH_GPHOTO2="$(usex gphoto2)"
 		-DWITH_LAPACK="$(multilib_native_usex lapack)"
-		-DWITH_ITT="no" # 3dparty libs itt_notify
+		-DWITH_ITT="no" # vendored ittnotify (Intel ITT)
+		-DWITH_ZLIB_NG="no" # vendored zlib-ng
 	# ===================================================
 	# CUDA build components: nvidia-cuda-toolkit
 	# ===================================================
@@ -690,14 +695,47 @@
 
 	if multilib_is_native_abi && use cuda; then
 		cuda_add_sandbox -w
-		addwrite "/proc/self/task"
-		CUDAHOSTCXX="$(cuda_get_cuda_compiler)"
-		CUDAARCHS="$(cuda_get_host_native_arch)"
-		export CUDAHOSTCXX
-		export CUDAARCHS
+		addwrite /proc/self/task
+
+		export CUDAHOSTCXX="$(cuda_get_host_compiler)"
+		export CXX="${CUDAHOSTCXX/gcc/g++}"
+		export CC="${CUDAHOSTCXX}"
+
+		if [[ -z "${CUDAARCHS}" ]]; then
+			# CUDAARCHS must be set in order to prevent possible miscalculation and
+			# overriding of CUDA_ARCH_BIN and CUDA_ARCH_PTX by OpenCV's CMake scripts
+			# due to https://github.com/opencv/opencv/issues/25920
+			if [[ -n "${CUDA_ARCH_BIN}" ]]; then
+				export CUDAARCHS="${CUDA_ARCH_BIN//./}"
+			else
+				export CUDAARCHS="$(cuda_get_host_native_arch)"
+			fi
+		fi
+
+		einfo "CUDAHOSTCXX: ${CUDAHOSTCXX}"
+		einfo "CUDAARCHS: ${CUDAARCHS}"
+		einfo "CUDA_ARCH_BIN: ${CUDA_ARCH_BIN:=${CUDAARCHS}}"
+		einfo "CUDA_ARCH_PTX: ${CUDA_ARCH_PTX:=${CUDAARCHS}}"
+		einfo "CUDA_GENERATION: ${CUDA_GENERATION}"
+
+		# WARNING: there is a bug that makes CMake to igore
+		# CUDA_ARCH_BIN/PTX and CUDA_GENERATION options in case
+		# the ENABLE_CUDA_FIRST_CLASS_LANGUAGE is set to "yes"
+		# https://github.com/opencv/opencv/issues/25920
+		# So the configuration below is broken at the moment.
+		# Please rely on the CUDAARCHS env variable for now!
+
 		mycmakeargs+=(
 			-DENABLE_CUDA_FIRST_CLASS_LANGUAGE="yes"
+			-DCUDA_ARCH_BIN="${CUDA_ARCH_BIN}"
+			-DCUDA_ARCH_PTX="${CUDA_ARCH_PTX}"
 		)
+
+		if [[ -n "${CUDA_GENERATION}" ]]; then
+			mycmakeargs+=(
+				-DCUDA_GENERATION="${CUDA_GENERATION}"
+			)
+		fi
 	fi
 
 	if use ffmpeg; then
@@ -804,20 +842,8 @@
 		'AsyncAPICancelation/cancel*basic'
 	)
 
-	if ! use gtk && ! use qt5 && ! use qt6; then
-		CMAKE_SKIP_TESTS+=(
-			# these fail with parallism
-			'^Highgui_*'
-		)
-	fi
-
-	if multilib_is_native_abi && use cuda; then
-		CMAKE_SKIP_TESTS+=(
-			'CUDA_OptFlow/BroxOpticalFlow.Regression/0'
-			'CUDA_OptFlow/BroxOpticalFlow.OpticalFlowNan/0'
-			'CUDA_OptFlow/NvidiaOpticalFlow_1_0.Regression/0'
-			'CUDA_OptFlow/NvidiaOpticalFlow_2_0.Regression/0'
-		)
+	if ! use gtk3 && ! use qt5 && ! use qt6; then
+		CMAKE_SKIP_TESTS+=( '^Highgui_*' )
 	fi
 
 	if use opengl; then
@@ -839,8 +865,17 @@
 
 	if multilib_is_native_abi && use cuda; then
 		cuda_add_sandbox -w
+		addwrite /proc/self/task
 		export OPENCV_PARALLEL_BACKEND="threads"
 		export DNN_BACKEND_OPENCV="cuda"
+		CMAKE_SKIP_TESTS+=(
+			'CUDA_OptFlow/BroxOpticalFlow.Regression/0'
+			'CUDA_OptFlow/BroxOpticalFlow.OpticalFlowNan/0'
+			'CUDA_OptFlow/NvidiaOpticalFlow_1_0.Regression/0'
+			'CUDA_OptFlow/NvidiaOpticalFlow_1_0.OpticalFlowNan/0'
+			'CUDA_OptFlow/NvidiaOpticalFlow_2_0.Regression/0'
+			'CUDA_OptFlow/NvidiaOpticalFlow_2_0.OpticalFlowNan/0'
+		)
 	fi
 
 	opencv_test() {

Best regards!


  • I can submit this contribution in agreement with the Copyright Policy.
  • I have certified the above via adding a Signed-off-by line to every commit in the pull request.
  • This contribution has not been created with the assistance of Natural Language Processing artificial intelligence tools, in accordance with the AI policy.
  • I have run pkgcheck scan --commits --net to check for issues with my commits.

@gentoo-bot gentoo-bot added assigned PR successfully assigned to the package maintainer(s). bug linked Bug/Closes found in footer, and cross-linked with the PR. labels Jul 8, 2024
@gentoo-repo-qa-bot
Copy link
Copy Markdown
Collaborator

Pull request CI report

Report generated at: 2024-07-08 03:07 UTC
Newest commit scanned: 3355c6a
Status: ✅ good

There are existing issues already. Please look into the report to make sure none of them affect the packages in question:
https://qa-reports.gentoo.org/output/gentoo-ci/f8d1b9821e/output.html

@gentoo-repo-qa-bot
Copy link
Copy Markdown
Collaborator

Pull request CI report

Report generated at: 2024-07-09 00:07 UTC
Newest commit scanned: d6b7459
Status: ✅ good

There are existing issues already. Please look into the report to make sure none of them affect the packages in question:
https://qa-reports.gentoo.org/output/gentoo-ci/f006124ff8/output.html

@Jamim Jamim force-pushed the media-libs/opencv branch from d6b7459 to 6bac88e Compare July 9, 2024 23:42
@gentoo-repo-qa-bot
Copy link
Copy Markdown
Collaborator

Pull request CI report

Report generated at: 2024-07-10 00:02 UTC
Newest commit scanned: 6bac88e
Status: ✅ good

There are existing issues already. Please look into the report to make sure none of them affect the packages in question:
https://qa-reports.gentoo.org/output/gentoo-ci/d4198251a6/output.html

asmorkalov pushed a commit to opencv/opencv that referenced this pull request Jul 10, 2024
Fix CUDA for old GPUs without FP16 support #25880

Fixes #21461

~This is a build-time solution that reflects https://github.com/opencv/opencv/blob/4.10.0/modules/dnn/src/cuda4dnn/init.hpp#L68-L82.~
~We shouldn't add an invalid target while building with `CUDA_ARCH_BIN` < 53.~
_(please see [this discussion](#25880 (comment)

This is a run-time solution that basically reverts [these lines](d0fe6ad#diff-757c5ab6ddf2f99cdd09f851e3cf17abff203aff4107d908c7ad3d0466f39604L245-R245).

I've debugged these changes, [coupled with other fixes](gentoo/gentoo#37479), on [Gentoo Linux](https://www.gentoo.org/) and [related tests passed](https://github.com/user-attachments/files/16135391/opencv-4.10.0.20240708-224733.log.gz) on my laptop with `GeForce GTX 960M`.

Alternative solution:
  - #21462

_Best regards!_

### Pull Request Readiness Checklist

- [x] I agree to contribute to the project under Apache 2 License.
- [x] To the best of my knowledge, the proposed patch is not based on a code under GPL or another license that is incompatible with OpenCV
- [x] The PR is proposed to the proper branch
- [x] There is a reference to the original bug report and related work
- [ ] `n/a` There is accuracy test, performance test and test data in opencv_extra repository, if applicable
- [ ] `n/a` The feature is well documented and sample code can be built with the project CMake
@Jamim Jamim force-pushed the media-libs/opencv branch from 6bac88e to a1a11b2 Compare July 10, 2024 10:03
@gentoo-repo-qa-bot
Copy link
Copy Markdown
Collaborator

Pull request CI report

Report generated at: 2024-07-10 10:22 UTC
Newest commit scanned: a1a11b2
Status: ✅ good

There are existing issues already. Please look into the report to make sure none of them affect the packages in question:
https://qa-reports.gentoo.org/output/gentoo-ci/4543f8d5c6/output.html

@Jamim Jamim force-pushed the media-libs/opencv branch from a1a11b2 to 14efa54 Compare July 11, 2024 00:24
@gentoo-repo-qa-bot
Copy link
Copy Markdown
Collaborator

Pull request CI report

Report generated at: 2024-07-11 00:42 UTC
Newest commit scanned: 14efa54
Status: ✅ good

There are existing issues already. Please look into the report to make sure none of them affect the packages in question:
https://qa-reports.gentoo.org/output/gentoo-ci/4b1fef4d3d/output.html

@vaukai
Copy link
Copy Markdown
Contributor

vaukai commented Jul 11, 2024

wrt java see Required Java dependencies for optional Java support

@Jamim
Copy link
Copy Markdown
Contributor Author

Jamim commented Jul 11, 2024

Thank you for the review, @vaukai!

So far I've updated the ebuild in my overlay.
Do you mind if I add Co-authored-by and Signed-off-by to the commit message here?

Co-authored-by: Volkmar W. Pogatzki <gentoo@pogatzki.net>
Signed-off-by: Volkmar W. Pogatzki <gentoo@pogatzki.net>

@vaukai
Copy link
Copy Markdown
Contributor

vaukai commented Jul 11, 2024

Thank you for the review, @vaukai!

So far I've updated the ebuild in my overlay. Do you mind if I add Co-authored-by and Signed-off-by to the commit message here?

Co-authored-by: Volkmar W. Pogatzki <gentoo@pogatzki.net>
Signed-off-by: Volkmar W. Pogatzki <gentoo@pogatzki.net>

Please don't since that's unusual in Gentoo. Adjusting the ebuild according to Java_Developer_Guide is enough.

If you like you could try getting rid of java-ant-2 like i did this morning for mythtv but that's not a trivial change. I would otherwise do that after your PR got merged.
The reason for dropping java-ant-2 is that it runs BSFIX aka xml-rewrite provided by an undocumented black box called javatoolkit.

meanwhile i have 4.9.0-r2 ready to merge which no longer inherits java-ant-2.
Please try including those changes here.

@vaukai
Copy link
Copy Markdown
Contributor

vaukai commented Jul 11, 2024

@Jamim you want to move changelog from commit message to metadata.xml (compare https://gitweb.gentoo.org/repo/gentoo.git/tree/dev-java/tomcat-native/metadata.xml)

@Jamim Jamim force-pushed the media-libs/opencv branch from 14efa54 to de32b9f Compare July 11, 2024 13:49
@gentoo-repo-qa-bot
Copy link
Copy Markdown
Collaborator

Pull request CI report

Report generated at: 2024-07-11 14:07 UTC
Newest commit scanned: de32b9f
Status: ✅ good

There are existing issues already. Please look into the report to make sure none of them affect the packages in question:
https://qa-reports.gentoo.org/output/gentoo-ci/4ed1ae1fed/output.html

@Jamim Jamim force-pushed the media-libs/opencv branch from de32b9f to 5249f21 Compare July 11, 2024 14:14
@Jamim
Copy link
Copy Markdown
Contributor Author

Jamim commented Jul 11, 2024

@vaukai I've added changelog and doc links to the metadata.xml.
However, I prefer to keep a link to the certain changelog section in the commit message.

@Jamim Jamim requested a review from vaukai July 11, 2024 14:17
@gentoo-repo-qa-bot
Copy link
Copy Markdown
Collaborator

Pull request CI report

Report generated at: 2024-07-11 14:32 UTC
Newest commit scanned: 5249f21
Status: ✅ good

There are existing issues already. Please look into the report to make sure none of them affect the packages in question:
https://qa-reports.gentoo.org/output/gentoo-ci/1fb99a6e32/output.html

Copy link
Copy Markdown
Member

@eli-schwartz eli-schwartz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please split this PR up into logically distinct commits. It's okay to have multiple commits in a single PR.

In particular:

  • do not update multiple packages in a single commit. If updating opencv depends on making changes to acct-*/ packages, do not silently make that change inside the opencv bump
  • adding new metadata to metadata.xml is unrelated to bumping the version. It's completely fine to do them both in the same PR: it just makes more sense to do them as separate, logically distinct commits. This means that if, for example, there's a problem with the opencv bump and it needs to be reverted, the metadata.xml change doesn't get reverted alongside it.
  • in general, if your commit message says "also changes" with a list of "also changed" things, it may be a sign that the things you are changing have nothing to do with the subject of the commit, and could be done via a separate commit

@eli-schwartz
Copy link
Copy Markdown
Member

However, I prefer to keep a link to the certain changelog section in the commit message.

Please don't...

@Jamim Jamim force-pushed the media-libs/opencv branch from 5249f21 to 5ef350c Compare July 11, 2024 15:18
@Jamim
Copy link
Copy Markdown
Contributor Author

Jamim commented Jul 11, 2024

Hello @eli-schwartz,
Thank you! I've split the PR into distinct commits.

@Jamim
Copy link
Copy Markdown
Contributor Author

Jamim commented Jul 11, 2024

Hello @negril,

Could you please review this PR?

Thanks in advance!

@Delicates
Copy link
Copy Markdown

Delicates commented Jul 16, 2024

14efa54 builds fine for me with nVIDIA proprietary drivers.

All branches after that fail config with the following error:

 * abi_x86_64.amd64: running multilib-minimal_abi_src_configure
__nvcc_device_query failed to call cudaLoader::cuInit(0) with error 0x64 (CUDA_ERROR_NO_DEVICE)
__nvcc_device_query failed to call cudaLoader::cuInit(0) with error 0x64 (CUDA_ERROR_NO_DEVICE)
 * ERROR: media-libs/opencv-4.10.0::local_overlay failed (configure phase):
 *   Failed to get CUDA host native arch
 * 
 * Call stack:
 *     ebuild.sh, line  136:  Called src_configure
 *   environment, line 5698:  Called cmake-multilib_src_configure
 *   environment, line 1335:  Called multilib-minimal_src_configure
 *   environment, line 4407:  Called multilib_foreach_abi 'multilib-minimal_abi_src_configure'
 *   environment, line 4657:  Called multibuild_foreach_variant '_multilib_multibuild_wrapper' 'multilib-minimal_abi_src_configure'
 *   environment, line 4362:  Called _multibuild_run '_multilib_multibuild_wrapper' 'multilib-minimal_abi_src_configure'
 *   environment, line 4360:  Called _multilib_multibuild_wrapper 'multilib-minimal_abi_src_configure'
 *   environment, line  608:  Called multilib-minimal_abi_src_configure
 *   environment, line 4401:  Called multilib_src_configure
 *   environment, line 4923:  Called cuda_get_host_native_arch
 *   environment, line 1814:  Called die
 * The specific snippet of code:
 *       : "${CUDAARCHS:=$(__nvcc_device_query || __nvcc_device_query || die 'Failed to get CUDA host native arch')}";

For comparison, the 14efa54 successful config looks like so:

 * abi_x86_64.amd64: running multilib-minimal_abi_src_configure
__nvcc_device_query failed to call cudaLoader::cuInit(0) with error 0x64 (CUDA_ERROR_NO_DEVICE)
 * CUDAHOSTCXX: gcc-13
 * CUDAARCHS: 
 * CUDA_ARCH_BIN: 5.2
 * CUDA_ARCH_PTX: 

@Jamim Jamim force-pushed the media-libs/opencv branch from 5ef350c to 83a0530 Compare July 17, 2024 04:19
@Jamim
Copy link
Copy Markdown
Contributor Author

Jamim commented Jul 17, 2024

Hello @Delicates,

First of all, thank you for testing! 🙇🏼

Normally, __nvcc_device_query just prints 50 on my laptop with GeForce GTX 960M:

$ __nvcc_device_query
50

But in rare cases, it fails with the following message:

__nvcc_device_query failed to call cudaLoader::cuInit(0) with error 0x3e7 (CUDA_ERROR_UNKNOWN)

With 14efa54, __nvcc_device_query's failures were ignored, so that's why CUDAARCHS was empty. And in my case, empty CUDAARCHS value caused CUDA_ARCH_BIN/CUDA_ARCH_PTX miscalculation in OpenCV's CMake scripts, so I had 52 instead of 50 which was not really compatible with my GPU. That's why I added a retry and the explicit die when it fails twice in a row.

In your case, I see that __nvcc_device_query constantly can't find any CUDA device for some reason.
Can you please provide a bit more information about your system?

  • what GPUs are installed?
  • what nvidia-smi shows?

Also, it shouldn't fail in case you set a desired value to CUDAARCHS in make.conf or to the environment when you build opencv.

I've get rid of the die in favor of a warning for now. You can test it with 83a0530.

Also, I've found a very annoying bug related to CUDA configuration:

I'm not sure what's the best way to handle this situation, so any suggestions are welcome.

Thanks!

@gentoo-repo-qa-bot
Copy link
Copy Markdown
Collaborator

Pull request CI report

Report generated at: 2024-07-17 04:38 UTC
Newest commit scanned: 83a0530
Status: ✅ good

There are existing issues already. Please look into the report to make sure none of them affect the packages in question:
https://qa-reports.gentoo.org/output/gentoo-ci/e6c9ae5966/output.html

@Delicates
Copy link
Copy Markdown

Прывітанне @Jamim

Thanks for tackling this OpenCV version bump, it's been a blocker for many things.

I've get rid of the die in favor of a warning for now. You can test it with 83a0530.

This seems to work better than any of the prior versions without any make.conf updates - no config error at all:

 * abi_x86_64.amd64: running multilib-minimal_abi_src_configure
 * CUDAHOSTCXX: gcc-13
 * CUDAARCHS: 52
 * CUDA_ARCH_BIN: 5.2
 * CUDA_ARCH_PTX: 52
 * CUDA_GENERATION: Maxwell

With 14efa54, __nvcc_device_query's failures were ignored, so that's why CUDAARCHS was empty. And in my case, empty CUDAARCHS value caused CUDA_ARCH_BIN/CUDA_ARCH_PTX miscalculation in OpenCV's CMake scripts, so I had 52 instead of 50 which was not really compatible with my GPU. That's why I added a retry and the explicit die when it fails twice in a row.

I know 52 is currently the default arch in CUDA, and it would be annoying if it doesn't match your GPU.
My GPU actually happens to be 52 arch, so I guess the default always works in my favour.

+-----------------------------------------------------------------------------------------+
| NVIDIA-SMI 555.58.02              Driver Version: 555.58.02      CUDA Version: 12.5     |
|-----------------------------------------+------------------------+----------------------+
| GPU  Name                 Persistence-M | Bus-Id          Disp.A | Volatile Uncorr. ECC |
| Fan  Temp   Perf          Pwr:Usage/Cap |           Memory-Usage | GPU-Util  Compute M. |
|                                         |                        |               MIG M. |
|=========================================+========================+======================|
|   0  NVIDIA GeForce GTX 970         Off |   00000000:02:00.0  On |                  N/A |
| 42%   40C    P0             56W /  250W |    1500MiB /   4096MiB |      8%      Default |
|                                         |                        |                  N/A |
+-----------------------------------------+------------------------+----------------------+

I did already have a few variables defined in my make.conf (not CUDAARCHS though), but looks like they were not helping with the previous version errors:

NVCCFLAGS="-O2 -gencode arch=compute_52,code=sm_52 -allow-unsupported-compiler"
CUDA_NVCC_FLAGS="${NVCCFLAGS}"
NVCC_FLAGS_EXTRA="${NVCCFLAGS}"
NVCC_PREPEND_FLAGS="${NVCCFLAGS}"
LLVM_TARGETS="NVPTX X86"

CUDA_NVCC_FLAGS="${NVCCFLAGS}"
CUDA_ARCH="sm_52"
CUDA_ARCH_BIN="5.2"
CUDA_GENERATION="Maxwell"
TORCH_CUDA_ARCH_LIST="5.2"

Copy link
Copy Markdown
Contributor

@vaukai vaukai left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if getting any trouble with proposed changes, pls tell

@Jamim
Copy link
Copy Markdown
Contributor Author

Jamim commented Sep 11, 2024

Hello @vaukai,
I've ported your changes from #37823 to this PR.
Thank you!

@Jamim Jamim requested a review from vaukai September 11, 2024 10:23
@gentoo-repo-qa-bot
Copy link
Copy Markdown
Collaborator

Pull request CI report

Report generated at: 2024-09-11 10:24 UTC
Newest commit scanned: c0b97f4
Status: ✅ good

There are existing issues already. Please look into the report to make sure none of them affect the packages in question:
https://qa-reports.gentoo.org/output/gentoo-ci/5b0efc1e68/output.html

@Jamim
Copy link
Copy Markdown
Contributor Author

Jamim commented Sep 11, 2024

Hello @eli-schwartz,
Do you still have any concerns here?

@vaukai
Copy link
Copy Markdown
Contributor

vaukai commented Sep 11, 2024

Hello @vaukai, I've ported your changes from #37823 to this PR. Thank you!

lgtm

@Jamim
Copy link
Copy Markdown
Contributor Author

Jamim commented Oct 5, 2024

Hello @juippis,

You asked me to stop pinging people and suggested to take a break.
Well, as you can see, this approach failed completely.

Does this PR have chances to be merged this year or, at least, to receive some additional feedback and be improved while I don't ping anyone?
I don't think so.

I state that there's something fundamentally wrong with contribution processing in Gentoo, so not only this PR got stuck, but hundreds of other PRs, whether they are good or bad, are lost and become irrelevant over time.

It's clear that there are not enough resources to process all the PRs, so maybe it's time to stop processing them at all for a moment, take a deep breath and think about what can be changed in the workflow? I believe there is room for improvements and optimizations, so maintainers can bring more value while spend less time. Please let me know if I can do anything to make it happen.

For context, I use Gentoo Linux since 2007.
Only a year ago or so I started trying to do my best to not only receive from it but also to return something valuable back. And what I can tell you so far is I was happier about Gentoo when I didn't care and just used it.

I understand this is not the right place to start this topic, but I'm tired and quite disappointed so here we go.

Thank you for your time and patience in reading this!

P.S. It would be nice if you share my concerns with those whom I shouldn't ping there.

@eli-schwartz
Copy link
Copy Markdown
Member

@Jamim,

The third PR still contains many changes that are all grouped into a single commit, with the implication that these are issues you encountered in 4.9.0-r2 as well. As I said above:

  • in general, if your commit message says "also changes" with a list of "also changed" things, it may be a sign that the things you are changing have nothing to do with the subject of the commit, and could be done via a separate commit

My initial review comment therefore is still outstanding.

And e.g. for https://bugs.gentoo.org/930368 you are NOT in fact fixing it, sorry -- so please remove the "Closes" link entirely if you are not going to do it correctly. (This is, again, the issue with making many changes in the same commit as incrementing the version number, when the changes aren't a result of incrementing the version number.)

And changes such as depending on a modified acct-user/portage package to "Allow access to GPUs during tests run" is a very... interesting change. I told you to divide it up into separate commits as a matter of git hygiene, that's not the same as saying I agree with such an acct-user change. But that aside, you haven't followed the bot instructions to

In order to force reassignment and/or bug reference scan, please append [please reassign] to the pull request title.

which appears to be necessary in order for the bot to notice that you are modifying the acct-user/portage package so the maintainers of that package are even notified of the need to review this PR.

The proxied maintainer for opencv itself still hasn't reviewed the PR, but that may be because it was hard to figure out what it's trying to do considering that it lists 13 different change requests in the commit message for the third commit and it's not necessarily clear which changes are tied to which change requests.

@Jamim Jamim changed the title ⬆️🚩🦺🐛 media-libs/opencv: add 4.10.0 ⬆️🚩🦺🐛 media-libs/opencv: add 4.10.0 [please reassign] Oct 7, 2024
@gentoo-bot gentoo-bot changed the title ⬆️🚩🦺🐛 media-libs/opencv: add 4.10.0 [please reassign] ⬆️🚩🦺🐛 media-libs/opencv: add 4.10.0 Oct 7, 2024
@gentoo-bot
Copy link
Copy Markdown

Pull Request assignment

Submitter: @Jamim
Areas affected: ebuilds
Packages affected: acct-user/portage, media-libs/opencv

acct-user/portage: @gentoo/portage
media-libs/opencv: @negril, @gentoo/proxy-maint

Linked bugs

Bugs linked: 930368, 930682, 928747


In order to force reassignment and/or bug reference scan, please append [please reassign] to the pull request title.

Docs: Code of ConductCopyright policy (expl.) ● DevmanualGitHub PRsProxy-maint guide

@gentoo-bot gentoo-bot added assigned PR successfully assigned to the package maintainer(s). bug linked Bug/Closes found in footer, and cross-linked with the PR. and removed assigned PR successfully assigned to the package maintainer(s). bug linked Bug/Closes found in footer, and cross-linked with the PR. labels Oct 7, 2024
Jamim added 3 commits November 2, 2024 03:52
Add changelog and doc urls to metadata.xml

Signed-off-by: Aliaksei Urbanski <aliaksei.urbanski@gmail.com>
Signed-off-by: Aliaksei Urbanski <aliaksei.urbanski@gmail.com>
Release:
  - https://github.com/opencv/opencv/releases/tag/4.10.0

Changes in comparison to 4.9.0-r2:
  - add the avif USE flag
  - add CUDA host compiler validation
  - update tesseract requirement
  - remove unnecessary restrictions
  - fix
    * missing gtk USE flag at multilib_src_test
    * CUDAARCHS/CUDA_ARCH_BIN/CUDA_ARCH_PTX configuration
    * compatibility for old GPUs without FP16 support
    * compatibility for cuDNN 9+
    * tests for CUDA/cuDNN
    * -ccbin calculation
    * missing access to GPUs during tests run
    * redundant virtual/jre in the COMMON_DEPEND

Bug: https://bugs.gentoo.org/928747
Bug: https://bugs.gentoo.org/930368
Bug: https://bugs.gentoo.org/930682
Signed-off-by: Aliaksei Urbanski <aliaksei.urbanski@gmail.com>
@Jamim Jamim force-pushed the media-libs/opencv branch from c0b97f4 to 5fb47eb Compare November 2, 2024 01:05
@gentoo-repo-qa-bot
Copy link
Copy Markdown
Collaborator

Pull request CI report

Report generated at: 2024-11-02 01:33 UTC
Newest commit scanned: 5fb47eb
Status: ✅ good

There are existing issues already. Please look into the report to make sure none of them affect the packages in question:
https://qa-reports.gentoo.org/output/gentoo-ci/4cf33ce414/output.html

@Jamim
Copy link
Copy Markdown
Contributor Author

Jamim commented Nov 2, 2024

Hello @eli-schwartz,

The third PR still contains many changes that are all grouped into a single commit, with the implication that these are issues you encountered in 4.9.0-r2 as well. As I said above:

  • in general, if your commit message says "also changes" with a list of "also changed" things, it may be a sign that the things you are changing have nothing to do with the subject of the commit, and could be done via a separate commit

It's not also changes now. It's changes in comparison to. As far as I can understand, you want me to copy 4.9.0-r2 as is to 4.10.0 in a dedicated commit and then to commit all the changes one by one, separately. If so, it would be perfectly fine to split the commit if I wanted to modify 4.9.0-r2. But it's not the case. opencv-4.10.0 is a new ebuild, and I don't want to add unnecessary commits here. No one except you asks for such a detailed history, so I don't see any benefits of doing so.

And e.g. for bugs.gentoo.org/930368 you are NOT in fact fixing it, sorry -- so please remove the "Closes" link entirely if you are not going to do it correctly. (This is, again, the issue with making many changes in the same commit as incrementing the version number, when the changes aren't a result of incrementing the version number.)

I suppose you got something mixed up. There was no Closes link in commit messages. There were Bug links only. So there's nothing to remove. In the meantime, any suggestions on how to correctly resolve 930368 are welcome.

And changes such as depending on a modified acct-user/portage package to "Allow access to GPUs during tests run" is a very... interesting change. I told you to divide it up into separate commits as a matter of git hygiene, that's not the same as saying I agree with such an acct-user change.

Do you have any better ideas on how to allow tests to use the GPU? Is there any... boring way to do so?

But that aside, you haven't followed the bot instructions to

In order to force reassignment and/or bug reference scan, please append [please reassign] to the pull request title.

which appears to be necessary in order for the bot to notice that you are modifying the acct-user/portage package so the maintainers of that package are even notified of the need to review this PR.

Thanks for catching this! 🙇🏼

The proxied maintainer for opencv itself still hasn't reviewed the PR, but that may be because it was hard to figure out what it's trying to do considering that it lists 13 different change requests in the commit message for the third commit and it's not necessarily clear which changes are tied to which change requests.

Sorry, but it looks like a pure speculation. I believe @negril can speak for himself if he wants to.

@Jamim Jamim mentioned this pull request Jun 24, 2025
4 tasks
@LinuxUserGD
Copy link
Copy Markdown
Contributor

Current opencv version in Gentoo is 4.12.0-r1
Maybe this PR could be closed or rebased with the video useflag change?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

assigned PR successfully assigned to the package maintainer(s). bug linked Bug/Closes found in footer, and cross-linked with the PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants