diff options
author | Paul Zander <negril.nx+gentoo@gmail.com> | 2024-11-04 18:12:42 +0100 |
---|---|---|
committer | Sam James <sam@gentoo.org> | 2024-11-05 02:02:34 +0000 |
commit | a3c86c1428052831632d404877d328db8427efaf (patch) | |
tree | c2e70b1844e17723b4fe86be8c702cd788ed4d3c /media-libs/opencv/opencv-4.10.0.ebuild | |
parent | media-libs/opencv: wire up host linker for CUDA #928605 (diff) | |
download | gentoo-a3c86c1428052831632d404877d328db8427efaf.tar.gz gentoo-a3c86c1428052831632d404877d328db8427efaf.tar.bz2 gentoo-a3c86c1428052831632d404877d328db8427efaf.zip |
media-libs/opencv: cuda device detection
Signed-off-by: Paul Zander <negril.nx+gentoo@gmail.com>
Signed-off-by: Sam James <sam@gentoo.org>
Diffstat (limited to 'media-libs/opencv/opencv-4.10.0.ebuild')
-rw-r--r-- | media-libs/opencv/opencv-4.10.0.ebuild | 29 |
1 files changed, 25 insertions, 4 deletions
diff --git a/media-libs/opencv/opencv-4.10.0.ebuild b/media-libs/opencv/opencv-4.10.0.ebuild index 181b70f84784..0f90b6e92d2b 100644 --- a/media-libs/opencv/opencv-4.10.0.ebuild +++ b/media-libs/opencv/opencv-4.10.0.ebuild @@ -371,8 +371,9 @@ cuda_get_host_compiler() { } cuda_get_host_native_arch() { - : "${CUDAARCHS:=$(__nvcc_device_query)}" - echo "${CUDAARCHS}" + [[ -n ${CUDAARCHS} ]] && echo "${CUDAARCHS}" + + __nvcc_device_query || die "failed to query the native device" } pkg_pretend() { @@ -385,6 +386,7 @@ pkg_pretend() { einfo "The CUDA architecture tuple for your device can be found at https://developer.nvidia.com/cuda-gpus." fi + # When building binpkgs you probably want to include all targets 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." @@ -396,6 +398,13 @@ pkg_pretend() { pkg_setup() { [[ ${MERGE_TYPE} != binary ]] && use openmp && tc-check-openmp use java && java-pkg-opt-2_pkg_setup + + if use cuda && [[ ! -e /dev/nvidia-uvm ]]; then + # NOTE We try to load nvidia-uvm and nvidia-modeset here, + # so __nvcc_device_query does not fail later. + + nvidia-modprobe -m -u -c 0 || true + fi } src_prepare() { @@ -774,10 +783,22 @@ multilib_src_configure() { cuda_add_sandbox -w addwrite "/proc/self/task" + if ! test -w /dev/nvidiactl; then + # eqawarn "Can't access the GPU at /dev/nvidiactl." + # eqawarn "User $(id -nu) is not in the group \"video\"." + if [[ -z "${CUDA_GENERATION}" ]] && [[ -z "${CUDA_ARCH_BIN}" ]]; then + # build all targets + mycmakeargs+=( + -DCUDA_GENERATION="" + ) + fi + else + local -x CUDAARCHS + : "${CUDAARCHS:="$(cuda_get_host_native_arch)"}" + fi + local -x CUDAHOSTCXX CUDAHOSTLD CUDAHOSTCXX="$(cuda_get_host_compiler)" - CUDAARCHS="$(cuda_get_host_native_arch)" - export CUDAARCHS CUDAHOSTLD="$(tc-getCXX)" if tc-is-gcc; then |