4.8.0.74: `Exception: Not found: 'python/cv2/py.typed'` when building a contrib wheel with CUDA
Expected behaviour
Build a python-3.11 contrib wheel
Actual behaviour
Creating the wheel failed with this error:
Copying files from CMake output
creating directory _skbuild/linux-x86_64-3.11/cmake-install/cv2
copying _skbuild/linux-x86_64-3.11/cmake-install/python/cv2/python-3/cv2.abi3.so -> _skbuild/linux-x86_64-3.11/cmake-install/cv2/cv2.abi3.so
copying _skbuild/linux-x86_64-3.11/cmake-install/python/cv2/__init__.py -> _skbuild/linux-x86_64-3.11/cmake-install/cv2/__init__.py
copying _skbuild/linux-x86_64-3.11/cmake-install/python/cv2/load_config_py2.py -> _skbuild/linux-x86_64-3.11/cmake-install/cv2/load_config_py2.py
copying _skbuild/linux-x86_64-3.11/cmake-install/python/cv2/load_config_py3.py -> _skbuild/linux-x86_64-3.11/cmake-install/cv2/load_config_py3.py
copying _skbuild/linux-x86_64-3.11/cmake-install/python/cv2/config.py -> _skbuild/linux-x86_64-3.11/cmake-install/cv2/config.py
copying _skbuild/linux-x86_64-3.11/cmake-install/python/cv2/config-3.py -> _skbuild/linux-x86_64-3.11/cmake-install/cv2/config-3.py
Traceback (most recent call last):
File "/home/alex/T7/src/opencv-python/venv/lib/python3.11/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 353, in <module>
main()
File "/home/alex/T7/src/opencv-python/venv/lib/python3.11/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 335, in main
json_out['return_val'] = hook(**hook_input['kwargs'])
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/alex/T7/src/opencv-python/venv/lib/python3.11/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 251, in build_wheel
return _build_backend().build_wheel(wheel_directory, config_settings,
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/tmp/pip-build-env-mheswsk1/overlay/lib/python3.11/site-packages/setuptools/build_meta.py", line 230, in build_wheel
return self._build_with_temp_dir(['bdist_wheel'], '.whl',
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/tmp/pip-build-env-mheswsk1/overlay/lib/python3.11/site-packages/setuptools/build_meta.py", line 215, in _build_with_temp_dir
self.run_setup()
File "/tmp/pip-build-env-mheswsk1/overlay/lib/python3.11/site-packages/setuptools/build_meta.py", line 268, in run_setup
self).run_setup(setup_script=setup_script)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/tmp/pip-build-env-mheswsk1/overlay/lib/python3.11/site-packages/setuptools/build_meta.py", line 158, in run_setup
exec(compile(code, __file__, 'exec'), locals())
File "setup.py", line 532, in <module>
main()
File "setup.py", line 264, in main
skbuild.setup(
File "/tmp/pip-build-env-mheswsk1/overlay/lib/python3.11/site-packages/skbuild/setuptools_wrap.py", line 706, in setup
_classify_installed_files(
File "setup.py", line 445, in _classify_installed_files_override
raise Exception("Not found: '%s'" % relpath_re)
Exception: Not found: 'python/cv2/py.typed'
error: subprocess-exited-with-error
× Building wheel for opencv-contrib-python (pyproject.toml) did not run successfully.
│ exit code: 1
╰─> See above for output.
note: This error originates from a subprocess, and is likely not a problem with pip.
full command: /home/alex/T7/src/opencv-python/venv/bin/python3.11 /home/alex/T7/src/opencv-python/venv/lib/python3.11/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py build_wheel /tmp/tmpo050xxg7
cwd: /home/alex/T7/src/opencv-python
Building wheel for opencv-contrib-python (pyproject.toml) ... error
ERROR: Failed building wheel for opencv-contrib-python
Failed to build opencv-contrib-python
ERROR: Failed to build one or more wheels
Steps to reproduce
git clone https://github.com/opencv/opencv-python.git
cd opencv-python
git checkout tags/74 -b 4.8.0.74
git submodule update --init --recursive
python3.11 -m venv venv
source venv/bin/activate
pip install -U pip wheel
export CMAKE_ARGS="-DCMAKE_BUILD_TYPE=RELEASE -DWITH_CUDA=ON -DWITH_CUDNN=ON -DWITH_CUBLAS=ON -DWITH_TBB=ON -DOPENCV_DNN_CUDA=ON -DOPENCV_ENABLE_NONFREE=ON -DCUDA_ARCH_BIN=7.5 -DBUILD_EXAMPLES=OFF -DHAVE_opencv_python3=ON"
export ENABLE_CONTRIB=1
pip wheel . --verbose
The same scenario built fine with 4.7.0.72, I assume it is related to b534ea27a65acc766575bdface4abc984178eee8
- Ubuntu 22.04
- architecture amd64
- opencv-python 4.8.0.74
Issue submission checklist
-
[x] This is not a generic OpenCV usage question (looking for help for coding, other usage questions, homework etc.)
- [x] I have read the README of this repository and understand that this repository provides only an automated build toolchain for OpenCV Python packages (there is no actual OpenCV code here)
- [x] The issue is related to the build scripts in this repository, to the pre-built binaries or is a feature request (such as "please enable this additional dependency")
-
[x] I'm using the latest version of
opencv-python
Python type stubs are not generated by some reason. I reproduced the issue locally with python3.8. Looks like it's somehow related to CUDA modules.
/mnt/projects/Projects/OpenCV/opencv-master/modules/python/src2/typing_stubs_generator.py:52: UserWarning: Typing stubs generation has failed.
Traceback (most recent call last):
File "/mnt/projects/Projects/OpenCV/opencv-master/modules/python/src2/typing_stubs_generator.py", line 49, in wrapped_func
ret_type = func(*args, **kwargs)
File "/mnt/projects/Projects/OpenCV/opencv-master/modules/python/src2/typing_stubs_generator.py", line 148, in _generate
generate_typing_stubs(self.cv_root, output_path)
File "/mnt/projects/Projects/OpenCV/opencv-master/modules/python/src2/typing_stubs_generation/generation.py", line 86, in generate_typing_stubs
root.resolve_type_nodes()
File "/mnt/projects/Projects/OpenCV/opencv-master/modules/python/src2/typing_stubs_generation/nodes/namespace_node.py", line 106, in resolve_type_nodes
raise TypeResolutionError(
typing_stubs_generation.nodes.type_node.TypeResolutionError: Failed to resolve "cv2" namespace against "None". Errors: ['Failed to resolve "cv2.cuda" namespace against "cv2". Errors: [\'Failed to resolve "cv2.cuda.NvidiaOpticalFlow_1_0" class against "cv2". Errors: [\\\'Failed to resolve "cv2.cuda.NvidiaOpticalFlow_1_0.create" function against "cv2". Errors: [0]: Failed to resolve "perfPreset" argument: Failed to resolve "cuda_NvidiaOpticalFlow_1_0_NVIDIA_OF_PERF_LEVEL" exposed as "cuda_NvidiaOpticalFlow_1_0_NVIDIA_OF_PERF_LEVEL"\\\']\', \'Failed to resolve "cv2.cuda.NvidiaOpticalFlow_2_0" class against "cv2". Errors: [\\\'Failed to resolve "cv2.cuda.NvidiaOpticalFlow_2_0.create" function against "cv2". Errors: [0]: Failed to resolve "perfPreset" argument: Failed to resolve "cuda_NvidiaOpticalFlow_2_0_NVIDIA_OF_PERF_LEVEL" exposed as "cuda_NvidiaOpticalFlow_2_0_NVIDIA_OF_PERF_LEVEL", [1]: Failed to resolve "outputGridSize" argument: Failed to resolve "cuda_NvidiaOpticalFlow_2_0_NVIDIA_OF_OUTPUT_VECTOR_GRID_SIZE" exposed as "cuda_NvidiaOpticalFlow_2_0_NVIDIA_OF_OUTPUT_VECTOR_GRID_SIZE", [2]: Failed to resolve "hintGridSize" argument: Failed to resolve "cuda_NvidiaOpticalFlow_2_0_NVIDIA_OF_HINT_VECTOR_GRID_SIZE" exposed as "cuda_NvidiaOpticalFlow_2_0_NVIDIA_OF_HINT_VECTOR_GRID_SIZE", [3]: Failed to resolve "perfPreset" argument: Failed to resolve "cuda_NvidiaOpticalFlow_2_0_NVIDIA_OF_PERF_LEVEL" exposed as "cuda_NvidiaOpticalFlow_2_0_NVIDIA_OF_PERF_LEVEL", [4]: Failed to resolve "outputGridSize" argument: Failed to resolve "cuda_NvidiaOpticalFlow_2_0_NVIDIA_OF_OUTPUT_VECTOR_GRID_SIZE" exposed as "cuda_NvidiaOpticalFlow_2_0_NVIDIA_OF_OUTPUT_VECTOR_GRID_SIZE", [5]: Failed to resolve "hintGridSize" argument: Failed to resolve "cuda_NvidiaOpticalFlow_2_0_NVIDIA_OF_HINT_VECTOR_GRID_SIZE" exposed as "cuda_NvidiaOpticalFlow_2_0_NVIDIA_OF_HINT_VECTOR_GRID_SIZE"\\\']\']', 'Failed to resolve "cv2.cudacodec" namespace against "cv2". Errors: [\'Failed to resolve "cv2.cudacodec.createVideoWriter" function against "cv2". Errors: [0]: Failed to resolve "stream" argument: Failed to resolve "Stream" exposed as "Stream", [1]: Failed to resolve "stream" argument: Failed to resolve "Stream" exposed as "Stream"\', \'Failed to resolve "cv2.cudacodec.EncodeQp" class against "cv2". Errors: [\\\'Failed to resolve "qpInterP" property\\\', \\\'Failed to resolve "qpInterB" property\\\', \\\'Failed to resolve "qpIntra" property\\\']\', \'Failed to resolve "cv2.cudacodec.EncoderParams" class against "cv2". Errors: [\\\'Failed to resolve "targetQuality" property\\\']\', \'Failed to resolve "cv2.cudacodec.VideoReader" class against "cv2". Errors: [\\\'Failed to resolve "cv2.cudacodec.VideoReader.nextFrame" function against "cv2". Errors: [0]: Failed to resolve "frame" argument: Failed to resolve one of "GpuMat | None" items. Errors: [\\\\\\\'Failed to resolve "GpuMat" exposed as "GpuMat"\\\\\\\'], [1]: Failed to resolve "stream" argument: Failed to resolve "Stream" exposed as "Stream", [2]: Failed to resolve return type: Failed to resolve one of "tuple[bool, GpuMat]" items. Errors: [\\\\\\\'Failed to resolve "GpuMat" exposed as "GpuMat"\\\\\\\']\\\', \\\'Failed to resolve "cv2.cudacodec.VideoReader.grab" function against "cv2". Errors: [0]: Failed to resolve "stream" argument: Failed to resolve "Stream" exposed as "Stream"\\\', \\\'Failed to resolve "cv2.cudacodec.VideoReader.retrieve" function against "cv2". Errors: [0]: Failed to resolve "frame" argument: Failed to resolve one of "GpuMat | None" items. Errors: [\\\\\\\'Failed to resolve "GpuMat" exposed as "GpuMat"\\\\\\\'], [1]: Failed to resolve return type: Failed to resolve one of "tuple[bool, GpuMat]" items. Errors: [\\\\\\\'Failed to resolve "GpuMat" exposed as "GpuMat"\\\\\\\']\\\']\']']
warnings.warn(
Built target gen_opencv_python_source
@asmorkalov thanks! I think I remember seeing something like this with 4.7.0.72 too:
... Errors: [\\\\\\\'Failed to resolve "GpuMat" exposed as "GpuMat"\\\\\\\']\\\']\']']
And type hints for cv2.cuda really didn't work.
There are 2 major issues in cudacodec and cudaoptflow. In case if you do not use them, you can fix the issue by adding -DBUILD_opencv_cudacodec=OFF -DBUILD_opencv_cudaoptflow=OFF to your CMAKE_ARGS.
-DBUILD_opencv_cudaoptflow=OFF only disables building cv2.cuda.NvidiaOpticalFlow_1_0 and cv2.cuda.NvidiaOpticalFlow_2_0, not cv2.cuda.FarnebackOpticalFlow, right? I only need the latter. And I don't use cudacodec too. I will try a rebuild now.
FarnebackOpticalFlow will be disabled too. I'll try to find some solution in mean time.
Okay, I see. Thanks a lot!
Indeed, disabling cudacodec and cudaoptflow got the wheel built. Since it's missing FarnebackOpticalFlow I need, for now I just removed these lines from setup.py:
diff --git a/setup.py b/setup.py
index b17c11e..47647e6 100644
--- a/setup.py
+++ b/setup.py
@@ -130,8 +130,6 @@ def main():
[
r"python/cv2/.*config.*.py"
]
- +
- [ r"python/cv2/py.typed" ] if sys.version_info >= (3, 6) else []
,
"cv2.data": [ # OPENCV_OTHER_INSTALL_PATH
("etc" if os.name == "nt" else "share/opencv4") + r"/haarcascades/.*\.xml"
Related:
- https://github.com/opencv/opencv/issues/23945
- https://github.com/opencv/opencv/issues/23946
I tried to compile git 4.x (705bb5d2554b12a0c1f9ae9050e88af0c588e799) now, still doesn't work. I can't compile since a long time already. That's why I used (45e535e34d3dc21cd4b798267bfa94ee7c61e11c) instead all the time. That works. If I try latest, I get:
RUN pip install scikit-build && \
git clone --recursive https://github.com/opencv/opencv-python && \
cd opencv-python && \
git submodule update --init --recursive && \
git submodule update --remote --merge && \
CMAKE_ARGS="-DOPENCV_EXTRA_MODULES_PATH=/workspace/opencv-python/opencv_contrib/modules \
-D BUILD_TIFF=ON \
-D BUILD_opencv_java=OFF \
-D WITH_CUDA=ON \
-D WITH_OPENGL=ON \
-D WITH_OPENCL=ON \
-D WITH_IPP=ON \
-D WITH_TBB=ON \
-D WITH_EIGEN=ON \
-D WITH_V4L=OFF \
-D BUILD_TESTS=OFF \
-D BUILD_PERF_TESTS=OFF \
-D CMAKE_BUILD_TYPE=RELEASE \
-D OPENCV_FFMPEG_USE_FIND_PACKAGE=ON \
-D BUILD_SHARED_LIBS=OFF \
-D CUDA_ARCH_BIN=7.5,8.0,8.6,8.9,7.5+PTX,8.0+PTX,8.6+PTX,8.9+PTX \
-D CMAKE_BUILD_TYPE=RELEASE" \
ENABLE_CONTRIB=1 MAKEFLAGS="-j$(nproc)" \
python setup.py bdist_wheel --verbose
855.3 Copying files from CMake output
855.3 creating directory _skbuild/linux-x86_64-3.11/cmake-install/cv2
855.3 copying _skbuild/linux-x86_64-3.11/cmake-install/python/cv2/python-3/cv2.abi3.so -> _skbuild/linux-x86_64-3.11/cmake-install/cv2/cv2.abi3.so
855.6 copying _skbuild/linux-x86_64-3.11/cmake-install/python/cv2/__init__.py -> _skbuild/linux-x86_64-3.11/cmake-install/cv2/__init__.py
855.6 copying _skbuild/linux-x86_64-3.11/cmake-install/python/cv2/load_config_py2.py -> _skbuild/linux-x86_64-3.11/cmake-install/cv2/load_config_py2.py
855.6 copying _skbuild/linux-x86_64-3.11/cmake-install/python/cv2/load_config_py3.py -> _skbuild/linux-x86_64-3.11/cmake-install/cv2/load_config_py3.py
855.6 copying _skbuild/linux-x86_64-3.11/cmake-install/python/cv2/config.py -> _skbuild/linux-x86_64-3.11/cmake-install/cv2/config.py
855.6 copying _skbuild/linux-x86_64-3.11/cmake-install/python/cv2/config-3.py -> _skbuild/linux-x86_64-3.11/cmake-install/cv2/config-3.py
855.6 Traceback (most recent call last):
855.6 File "/workspace/opencv-python/setup.py", line 535, in <module>
855.6 main()
855.6 File "/workspace/opencv-python/setup.py", line 267, in main
855.6 skbuild.setup(
855.6 File "/usr/local/lib/python3.11/site-packages/skbuild/setuptools_wrap.py", line 706, in setup
855.6 _classify_installed_files(
855.6 File "/workspace/opencv-python/setup.py", line 448, in _classify_installed_files_override
855.6 raise Exception("Not found: '%s'" % relpath_re)
855.6 Exception: Not found: 'python/cv2/py.typed'
Removing [ r"python/cv2/py.typed" ] if sys.version_info >= (3, 6) else [] from setup.py does not work like suggested above.
866.5 copying _skbuild/linux-x86_64-3.11/cmake-install/python/cv2/mat_wrapper/__init__.py -> _skbuild/linux-x86_64-3.11/cmake-install/cv2/mat_wrapper/__init__.py
866.5 creating directory _skbuild/linux-x86_64-3.11/cmake-install/cv2/misc
866.5 copying _skbuild/linux-x86_64-3.11/cmake-install/python/cv2/misc/__init__.py -> _skbuild/linux-x86_64-3.11/cmake-install/cv2/misc/__init__.py
866.5 copying _skbuild/linux-x86_64-3.11/cmake-install/python/cv2/misc/version.py -> _skbuild/linux-x86_64-3.11/cmake-install/cv2/misc/version.py
866.5 creating directory _skbuild/linux-x86_64-3.11/cmake-install/cv2/utils
866.5 copying _skbuild/linux-x86_64-3.11/cmake-install/python/cv2/utils/__init__.py -> _skbuild/linux-x86_64-3.11/cmake-install/cv2/utils/__init__.py
866.5 Traceback (most recent call last):
866.5 File "/workspace/opencv-python/setup.py", line 533, in <module>
866.5 main()
866.5 File "/workspace/opencv-python/setup.py", line 265, in main
866.5 skbuild.setup(
866.5 File "/usr/local/lib/python3.11/site-packages/skbuild/setuptools_wrap.py", line 706, in setup
866.5 _classify_installed_files(
866.5 File "/workspace/opencv-python/setup.py", line 446, in _classify_installed_files_override
866.5 raise Exception("Not found: '%s'" % relpath_re)
866.5 Exception: Not found: 'python/cv2/typing/.*\.py'
Adding -DBUILD_opencv_cudacodec=OFF -DBUILD_opencv_cudaoptflow=OFF works, but I don't really want an incomplete OpenCV.
Removing
+
[ r"python/cv2/py.typed" ] if sys.version_info >= (3, 6) else []
and
if sys.version_info >= (3, 6):
rearrange_cmake_output_data["cv2.typing"] = ["python/cv2" + r"/typing/.*\.py"]
from setup.py can compile a whl file with cudacodec. But frame_count from output video is negative. Related issue: https://github.com/opencv/opencv_contrib/issues/3556
Still has error while compiling, but still usable for final whl:
2023-08-30T01:26:13.0435435Z /home/vsts/work/1/s/opencv-python/opencv/modules/python/src2/typing_stubs_generator.py:52: UserWarning: Typing stubs generation has failed.
2023-08-30T01:26:13.0435853Z Traceback (most recent call last):
2023-08-30T01:26:13.0436237Z File "/home/vsts/work/1/s/opencv-python/opencv/modules/python/src2/typing_stubs_generator.py", line 49, in wrapped_func
2023-08-30T01:26:13.0436492Z ret_type = func(*args, **kwargs)
2023-08-30T01:26:13.0437015Z File "/home/vsts/work/1/s/opencv-python/opencv/modules/python/src2/typing_stubs_generator.py", line 148, in _generate
2023-08-30T01:26:13.0437348Z generate_typing_stubs(self.cv_root, output_path)
2023-08-30T01:26:13.0437771Z File "/home/vsts/work/1/s/opencv-python/opencv/modules/python/src2/typing_stubs_generation/generation.py", line 86, in generate_typing_stubs
2023-08-30T01:26:13.0438098Z root.resolve_type_nodes()
2023-08-30T01:26:13.0438518Z File "/home/vsts/work/1/s/opencv-python/opencv/modules/python/src2/typing_stubs_generation/nodes/namespace_node.py", line 106, in resolve_type_nodes
2023-08-30T01:26:13.0438857Z raise TypeResolutionError(
2023-08-30T01:26:13.0442380Z typing_stubs_generation.nodes.type_node.TypeResolutionError: Failed to resolve "cv2" namespace against "None". Errors: ['Failed to resolve "cv2.cudacodec" namespace against "cv2". Errors: [\'Failed to resolve "cv2.cudacodec.createVideoWriter" function against "cv2". Errors: [0]: Failed to resolve "stream" argument: Failed to resolve "Stream" exposed as "Stream", [1]: Failed to resolve "stream" argument: Failed to resolve "Stream" exposed as "Stream"\', \'Failed to resolve "cv2.cudacodec.EncodeQp" class against "cv2". Errors: [\\\'Failed to resolve "qpInterP" property\\\', \\\'Failed to resolve "qpInterB" property\\\', \\\'Failed to resolve "qpIntra" property\\\']\', \'Failed to resolve "cv2.cudacodec.EncoderParams" class against "cv2". Errors: [\\\'Failed to resolve "targetQuality" property\\\']\', \'Failed to resolve "cv2.cudacodec.VideoReader" class against "cv2". Errors: [\\\'Failed to resolve "cv2.cudacodec.VideoReader.nextFrame" function against "cv2". Errors: [0]: Failed to resolve "frame" argument: Failed to resolve one of "GpuMat | None" items. Errors: [\\\\\\\'Failed to resolve "GpuMat" exposed as "GpuMat"\\\\\\\'], [1]: Failed to resolve "stream" argument: Failed to resolve "Stream" exposed as "Stream", [2]: Failed to resolve return type: Failed to resolve one of "tuple[bool, GpuMat]" items. Errors: [\\\\\\\'Failed to resolve "GpuMat" exposed as "GpuMat"\\\\\\\']\\\', \\\'Failed to resolve "cv2.cudacodec.VideoReader.grab" function against "cv2". Errors: [0]: Failed to resolve "stream" argument: Failed to resolve "Stream" exposed as "Stream"\\\', \\\'Failed to resolve "cv2.cudacodec.VideoReader.retrieve" function against "cv2". Errors: [0]: Failed to resolve "frame" argument: Failed to resolve one of "GpuMat | None" items. Errors: [\\\\\\\'Failed to resolve "GpuMat" exposed as "GpuMat"\\\\\\\'], [1]: Failed to resolve return type: Failed to resolve one of "tuple[bool, GpuMat]" items. Errors: [\\\\\\\'Failed to resolve "GpuMat" exposed as "GpuMat"\\\\\\\']\\\']\']']
This was fixed in https://github.com/opencv/opencv/pull/24022
@cudawarped
This was fixed in opencv/opencv#24022
Is this fix included in this repo (opencv-python)?
@cudawarped
This was fixed in https://github.com/opencv/opencv/pull/24022Is this fix included in this repo (opencv-python)?
When you build the latest version from this repo it should clone OpenCV at a point after that PR was added.
@cudawarped
I tried to build a docker with OpenCV and CUDA (Release 76 is the latest one and it seems to have the same commits as the main 4.x branch)
My Dockerfile launched with docker build -t python_cv .
FROM nvidia/cuda:12.2.0-devel-ubuntu20.04
RUN apt update && apt upgrade -y && apt install -y git
RUN git clone --recursive https://github.com/opencv/opencv-python.git --branch 76
RUN DEBIAN_FRONTEND=noninteractive apt install -y cmake gcc g++ \
qtbase5-dev \
libavcodec-dev libavformat-dev libswscale-dev \
libgstreamer-plugins-base1.0-dev libgstreamer1.0-dev \
libgtk-3-dev libgtk2.0-dev \
python3-dev python3-numpy python3-pip python3-dev
RUN python3 -m pip install --upgrade pip
ENV CMAKE_ARGS="-D CMAKE_BUILD_TYPE=RELEASE \
-D WITH_GSTREAMER=ON \
-D OPENCV_ENABLE_NONFREE=ON \
-D WITH_TBB=ON \
-D WITH_V4L=ON \
-D WITH_QT=OFF \
-D WITH_OPENGL=ON \
-D WITH_CUDA=ON \
-D OPENCV_DNN_CUDA=OFF \
-D ENABLE_FAST_MATH=1 \
-D CUDA_FAST_MATH=1 \
-D CUDA_ARCH_BIN=8.6 \
-D WITH_CUBLAS=1 \
-D OPENCV_EXTRA_MODULES_PATH=/opencv-python/opencv_contrib/modules"
RUN cd opencv-python && \
pip wheel . --verbose
RUN python3 -c "import cv2; print(cv2.getBuildInformation())"
CMD ["bash"]
And I still got error:
File "setup.py", line 535, in <module>
main()
File "setup.py", line 267, in main
skbuild.setup(
File "/tmp/pip-build-env-gn3jrp32/overlay/lib/python3.8/site-packages/skbuild/setuptools_wrap.py", line 706, in setup
_classify_installed_files(
File "setup.py", line 448, in _classify_installed_files_override
raise Exception("Not found: '%s'" % relpath_re)
Exception: Not found: 'python/cv2/py.typed'
error: subprocess-exited-with-error
Could you look at this?
Apologies, I just realized that when I built my latest version I had
export ENABLE_ROLLING=1
and on the .74 version I manually altered the build file not to check for the missing files.
You can check the full command line in Build Summary for my latest OpenCV python CUDA wheel.
I got this message when I compile with gcc 8 or 9. When I set gcc 7 default, compilation somehow works. I have ubuntu 20.04
export python="python3.8"
which $python
cmake -D CMAKE_BUILD_TYPE=RELEASE \
-D CMAKE_INSTALL_PREFIX=/usr \
-D OPENCV_EXTRA_MODULES_PATH=~/opencv_contrib/modules \
-D EIGEN_INCLUDE_PATH=/usr/include/eigen3 \
-D WITH_OPENCL=OFF \
-D ENABLE_FAST_MATH=ON \
-D WITH_CUDA=ON \
-D CUDNN_LIBRARY=/usr/lib/x86_64-linux-gnu/libcudnn.so.8.9.5 \
-D CUDNN_INCLUDE_DIR=/usr/include \
-D WITH_CUDNN=ON \
-D CUDA_ARCH_BIN=7.5+PTX \
-D CUDA_FAST_MATH=ON \
-D CUDA_ARCH_PTX="" \
-D WITH_CUBLAS=ON \
-D WITH_OPENMP=ON \
-D BUILD_TIFF=ON \
-D WITH_FFMPEG=ON \
-D WITH_GSTREAMER=ON \
-D WITH_TBB=ON \
-D BUILD_TBB=ON \
-D BUILD_TESTS=OFF \
-D WITH_EIGEN=ON \
-D WITH_V4L=ON \
-D WITH_LIBV4L=ON \
-D OPENCV_ENABLE_NONFREE=ON \
-D INSTALL_C_EXAMPLES=OFF \
-D INSTALL_PYTHON_EXAMPLES=OFF \
-D OPENCV_GENERATE_PKGCONFIG=ON \
-D BUILD_EXAMPLES=OFF \
-D WITH_QT=OFF \
-D WITH_GTK=OFF \
-D BUILD_NEW_PYTHON_SUPPORT=ON \
-D BUILD_opencv_python3=ON \
-D BUILD_opencv_python2=OFF \
-D HAVE_opencv_python2=OFF \
-D PYTHON3_EXECUTABLE=$(which $python) \
-D PYTHON3_INCLUDE_DIR=$($python -c "from distutils.sysconfig import get_python_inc; print(get_python_inc())") \
-D PYTHON3_INCLUDE_DIR2=$($python -c "from os.path import dirname; from distutils.sysconfig import get_config_h_filename; print(dirname(get_config_h_filename()))") \
-D PYTHON3_LIBRARY=$($python -c "from distutils.sysconfig import get_config_var;from os.path import dirname,join ; print(join(dirname(get_config_var('LIBPC')),get_config_var('LDLIBRARY')))") \
-D PYTHON3_NUMPY_INCLUDE_DIRS=$($python -c "import numpy; print(numpy.get_include())") \
-D PYTHON3_PACKAGES_PATH=$($python -c "import site; print(site.getsitepackages()[0])") \
..
Apologies, I just realized that when I built my latest version I had
export ENABLE_ROLLING=1
and on the .74 version I manually altered the build file not to check for the missing files.
You can check the full command line in Build Summary for my latest OpenCV python CUDA wheel.
tl;dr rolling option will revert the submodules, and submodules opencv/ and opencv_contrib/ will no longer be at the commit recorded in opencv-python during compilation.
@cudawarped The rolling option made my local compilation revert to an older commit of opencv and opencv-contrib. Upon inspecting the setup.py of opencv-python, rolling, enables git command git submodule update --init --recursive --remote opencv and git submodule update --init --recursive --remote opencv_contrib where --remote options reverts the commit of the submodules. During the build time, the submodules are reverted and opencv/ will be at a commit in April 2023 (the current master commit as of 22 Oct 2023).
This reversion makes all the progresses and PRs from April to now void. Even worse, if opencv-python diverges from master which I believe is the case for 4.x, 5.x, 3.x variants, we are compiling the wrong version of opencv when rolling is enabled.
I don't know if there is something wrong with my use of rolling option or it is a bug. Please pointing out how to use the rolling option if the following steps I did are wrong:
- Git clone the opencv-python project.
- Adding this local folder on my disk as a dependency in my other project.
- Modify the setup.py of opencv-python such that it bypasses the environment variable check of ENABLE_ROLLING and always set the corresponding variable in setup.py to True.
- In my other project, install the dependencies using poetry install with proper poetry update etc commands.
As I mentioned above, git submodule update --remote will revert the submodule to the "latest" version that git thinks, which is wrong (branch master) in this case. I did check this git command and confirm the reversion.
@hyliu1989
Note: There is no longer a need to use rolling as the python bindings generator will now checkout 4.8.1 where this has been fixed.
tl;dr rolling option will revert the submodules, and submodules opencv/ and opencv_contrib/ will no longer be at the commit recorded in opencv-python during compilation.
@cudawarped The rolling option made my local compilation revert to an older commit of opencv and opencv-contrib. Upon inspecting the setup.py of opencv-python, rolling, enables git command
git submodule update --init --recursive --remote opencvandgit submodule update --init --recursive --remote opencv_contribwhere--remoteoptions reverts the commit of the submodules. During the build time, the submodules are reverted and opencv/ will be at a commit in April 2023 (the current master commit as of 22 Oct 2023).
My Interpretation of the docs
This command will by default assume that you want to update the checkout to the default branch of the remote submodule repository (the one pointed to by HEAD on the remote). You can, however, set this to something different if you want. For example, if you want to have the DbConnector submodule track that repository’s “stable” branch, you can set it in either your .gitmodules file (so everyone else also tracks it), or just in your local .git/config file. Let’s set it in the .gitmodules file:
is that git submodule update --init --recursive --remote opencv will checkout the branch in the submodule that HEAD references if it is not explicitly specified in .gitmodules. Additionaly if I set export/set ENABLE_ROLLING=1 opencv and opencv_contrib both checkout the 4.x branch which unless I have configured something incorrectly is pointed to by HEAD on the remote
git remote show origin
* remote origin
Fetch URL: [email protected]:opencv/opencv.git
Push URL: [email protected]:opencv/opencv.git
HEAD branch: 4.x
Remote branches:
2.4 tracked
3.4 tracked
4.x tracked
5.x tracked
master tracked
next tracked
refs/remotes/origin/4.8.x stale (use 'git remote prune' to remove)
Local branches configured for 'git pull':
4.x merges with remote 4.x
master merges with remote master
Local refs configured for 'git push':
4.x pushes to 4.x (local out of date)
master pushes to master (up to date)
@cudawarped Unfortunately I just did a git clone [email protected]:opencv/opencv-python.git; cd opencv-python; git submodule update --init --recursive --remote opencv. When executing git log inside opencv-python/opencv/, it still shows that opencv/ is pointing to master which is currently at a commit in March 2023 (my bad in my previous comment saying April!).
Please check if this happens in your machine. Here I did a fresh git clone.
However, if you remove the --remote opencv in the git submodule update command, everything is as you mentioned at 4.8.1. I pointed this out mainly in reply to the build earlier with rolling enabled. This build does not work on my machine (Windows 10 64-bit) and I still have to revert the two lines mentioned in https://github.com/opencv/opencv-python/issues/871#issuecomment-1698297467 to workaround the missing type module. I followed the build option in https://github.com/cudawarped/opencv-python-cuda-wheels/releases/tag/4.8.0.20230804 and discovered that rolling with the --remote option actually makes the version become unexpected.