Arch Linux

Please read this before reporting a bug:
https://wiki.archlinux.org/title/Bug_reporting_guidelines

Do NOT report bugs when a package is just outdated, or it is in the AUR. Use the 'flag out of date' link on the package page, or the Mailing List.

REPEAT: Do NOT report bugs for outdated packages!
Tasklist

FS#56351 - [opencv] OpenCV 3.3.1 build with CUDA and Python 3.6.3

Attached to Project: Arch Linux
Opened by Adam Gradzki (agradzki) - Thursday, 16 November 2017, 17:26 GMT
Last edited by Antonio Rojas (arojas) - Sunday, 10 December 2017, 19:47 GMT
Task Type Feature Request
Category Packages: Extra
Status Closed
Assigned To Ray Rashif (schivmeister)
Antonio Rojas (arojas)
Architecture All
Severity Low
Priority Normal
Reported Version
Due in Version Undecided
Due Date Undecided
Percent Complete 100%
Votes 0
Private No

Details

I built atlas-lapack from source to maximize my hardware capabilities. This might also work for regular ATLAS. I have not tested with it. I did not use OpenBLAS at all.

OpenCVFindLAPACK.cmake needs to be edited because of C++ name mangling which prevents the linker from finding the appropriate ATLAS symbols.

Edit OpenCVFindLAPACK.cmake

Change:

if(NOT " ${__content_str}" STREQUAL " ${_lapack_include_str}")
file(WRITE "${CBLAS_H_PROXY_PATH}" "${_lapack_include_str}")
endif()

To:

if(NOT " ${__content_str}" STREQUAL " ${_lapack_include_str}")
file(WRITE "${CBLAS_H_PROXY_PATH}" "extern 'C' { ${_lapack_include_str} }")
endif()

#############################################################################

Here is a known good build configuration which worked for me.

OPENCV_VERSION="3.3.1"
PYTHON_VERSION="3.6.3"

CFLAGS="-march=native -O2 -pipe" \
CXXFLAGS="-march=native -O2 -pipe" \
cmake \
-D BUILD_TESTS=OFF \
-D ENABLE_PRECOMPILED_HEADERS=OFF \
-D CMAKE_INSTALL_PREFIX="/opt/opencv_${OPENCV_VERSION}_python_${PYTHON_VERSION}" \
-D OPENCV_EXTRA_MODULES_PATH="../../opencv_contrib-3.3.1/modules" \
-D BUILD_OPENCV_PYTHON2=OFF \
-D BUILD_OPENCV_PYTHON3=ON \
-D CUDA_NVCC_FLAGS="--expt-relaxed-constexpr -ccbin gcc-6" \
-D CUDA_GENERATION=Pascal \
-D WITH_CUDA=ON \
-D ENABLE_FAST_MATH=1 \
-D CUDA_FAST_MATH=1 \
-D WITH_CUBLAS=1 \
-D WITH_EIGEN=ON \
-D BUILD_TIFF=ON \
-D BUILD_OPENCV_JAVA=OFF \
-D BUILD_PERF_TESTS=OFF \
-D CMAKE_BUILD_TYPE=RELEASE \
-D PYTHON3_LIBRARY=$(python -c "import os.path; from distutils.sysconfig import get_config_var; print(os.path.join(get_config_var('LIBDIR'), get_config_var('LDLIBRARY')))") \
-D PYTHON3_EXECUTABLE=$(which python) \
-D PYTHON3_INCLUDE_DIR=$(python -c "from distutils.sysconfig import get_python_inc; print(get_python_inc())") \
-D PYTHON3_PACKAGES_PATH=$(python -c "from distutils.sysconfig import get_python_lib; print(get_python_lib())") ..
This task depends upon

Closed by  Antonio Rojas (arojas)
Sunday, 10 December 2017, 19:47 GMT
Reason for closing:  Fixed
Additional comments about closing:  opencv 3.3.1-3
Comment by Antonio Rojas (arojas) - Tuesday, 05 December 2017, 17:49 GMT
I have no idea what you're asking for here, or what it has to do with atlas, which is not even in the repos - can you clarify? Both python2 and python3 modules are included in the current package.
Comment by Adam Gradzki (agradzki) - Tuesday, 05 December 2017, 17:53 GMT
Is it possible to include the ability to build with atlas-lapack instead of openblas? Furthermore, why is openblas the blas implementation required by opencv when atlas is more commonly the default installed blas? A properly built atlas setup is faster than openblas.
Comment by Antonio Rojas (arojas) - Tuesday, 05 December 2017, 19:22 GMT
No idea what that openblas "requirement" is about, certainly it doesn't come from us since we don't even package openblas.

opencv 3.3.1-3 is built with generic lapack support, you can then plug-in any lapack implementation you want as long as it provides the liblapack.so and libcblas.so libraries. Please test if that works for you.
Comment by Antonio Rojas (arojas) - Sunday, 10 December 2017, 19:47 GMT
I'll take it as a yes

Loading...