-
-
Notifications
You must be signed in to change notification settings - Fork 56.3k
Description
System Information
Operating System / Platform: Windows 10 Pro
opencv: 4.10.0-pre - 4.x branch up to commit 1db6a8a
opencv_contrib: 4.x branch up to commit 1ed3dd2c
Anaconda3: 24.5.0
Python version: 3.11.7
Cuda: 12.4 or 12.5
Cudnn: 9.1.1
CMake: 3.29.3
Visual Studio 17 2022
Video_Codec_SDK_12.2.72
GPU: NVIDIA GeForce GTX 1070
CPU: Intel Core i5-6600k @3.50GHz
Detailed description
Followed the guidance here on building OpenCV from source. This is with a new, clean install of Windows 10 Pro and the dependencies listed above.
After building from source with Python integration, I'm seeing an error when attempting to import the Python module. The first error is a DLL not found. Following the guidance here and using Process Monitor it looks like the CUDA DLLs were not being found, so I include the Cuda bin directory. After attempting to import again there is an error that a DLL initialization routine failed.
Can't find much online for this error in the context of OpenCV, but this Stackoverflow question mentions that it could be an issue with the CPU not supporting AVX. I've confirmed that this CPU (Intel i5 6600k) support AVX. I also tried building with Cuda 12.4 thinking that it may be due to cudnn being incompatable with Cuda 12.5.
(base) C:\Users\dgard>python
Python 3.11.7 | packaged by Anaconda, Inc. | (main, Dec 15 2023, 18:05:47) [MSC v.1916 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import cv2
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Users\dgard\anaconda3\Lib\site-packages\cv2\__init__.py", line 181, in <module>
bootstrap()
File "C:\Users\dgard\anaconda3\Lib\site-packages\cv2\__init__.py", line 153, in bootstrap
native_module = importlib.import_module("cv2")
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\dgard\anaconda3\Lib\importlib\__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ImportError: DLL load failed while importing cv2: The specified module could not be found.
>>> import os
>>> os.add_dll_directory("C:\\Program Files\\NVIDIA GPU Computing Toolkit\\CUDA\\v12.5\\bin")
<AddedDllDirectory('C:\\Program Files\\NVIDIA GPU Computing Toolkit\\CUDA\\v12.5\\bin')>
>>> import cv2
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: DLL load failed while importing cv2: A dynamic link library (DLL) initialization routine failed.
>>>
Steps to reproduce
- Install the following, in order:
- Windows 10 Pro
- Visual Studio
- Anaconda3
- Cuda Toolkit
- Cudnn
- CMake
- Video_Codec_SDK_12.2.72
- Merge the Video Codec SDK
Interface
andLib
directories into the Cudav12.5\include
andv12.5\lib
directories respectively - Merge the Cudnn
\bin\12.4
,\include\12.4
, and\lib\12.4
directories into Cuda'sv12.5\bin
,v12.5\lib
,v12.5\include
directories respectively. - Run the following CMake command to generate the build configuration:
set CMAKE_BUILD_PARALLEL_LEVEL=4
"C:\Program Files\CMake\bin\cmake.exe" -H"C:\Users\dgard\opencvGPU\opencv" ^
-DOPENCV_EXTRA_MODULES_PATH="C:\Users\dgard\opencvGPU\opencv_contrib\modules" ^
-B"C:\Users\dgard\opencvGPU\build" -G"Visual Studio 17 2022" ^
-DINSTALL_TESTS=ON ^
-DINSTALL_C_EXAMPLES=ON ^
-DBUILD_EXAMPLES=ON ^
-DBUILD_opencv_world=ON ^
-DENABLE_CUDA_FIRST_CLASS_LANGUAGE=ON ^
-DWITH_CUDA=ON ^
-DCUDA_GENERATION=Auto ^
-DBUILD_opencv_python3=ON ^
-DPYTHON3_INCLUDE_DIR=C:/Users/dgard/anaconda3/include ^
-DPYTHON3_LIBRARY=C:/Users/dgard/anaconda3/libs/python311.lib ^
-DPYTHON3_EXECUTABLE=C:/Users/dgard/anaconda3/python.exe ^
-DPYTHON3_NUMPY_INCLUDE_DIRS=C:/Users/dgard/anaconda3/Lib/site-packages/numpy/core/include ^
-DPYTHON3_PACKAGES_PATH=C:/Users/dgard/anaconda3/Lib/site-packages
The CMake configuration for the build was:
-- General configuration for OpenCV 4.10.0-pre =====================================
-- Version control: 4.9.0-546-g1db6a8a1f3
--
-- Extra modules:
-- Location (extra): C:/Users/dgard/opencvGPU/opencv_contrib/modules
-- Version control (extra): 4.9.0-83-g1ed3dd2c
--
-- Platform:
-- Timestamp: 2024-06-01T08:06:09Z
-- Host: Windows 10.0.19045 AMD64
-- CMake: 3.29.3
-- CMake generator: Visual Studio 17 2022
-- CMake build tool: C:/Program Files/Microsoft Visual Studio/2022/Community/MSBuild/Current/Bin/amd64/MSBuild.exe
-- MSVC: 1940
-- Configuration: Debug Release
--
-- CPU/HW features:
-- Baseline: SSE SSE2 SSE3
-- requested: SSE3
-- Dispatched code generation: SSE4_1 SSE4_2 FP16 AVX AVX2 AVX512_SKX
-- requested: SSE4_1 SSE4_2 AVX FP16 AVX2 AVX512_SKX
-- SSE4_1 (18 files): + SSSE3 SSE4_1
-- SSE4_2 (2 files): + SSSE3 SSE4_1 POPCNT SSE4_2
-- FP16 (1 files): + SSSE3 SSE4_1 POPCNT SSE4_2 FP16 AVX
-- AVX (9 files): + SSSE3 SSE4_1 POPCNT SSE4_2 AVX
-- AVX2 (38 files): + SSSE3 SSE4_1 POPCNT SSE4_2 FP16 FMA3 AVX AVX2
-- AVX512_SKX (8 files): + SSSE3 SSE4_1 POPCNT SSE4_2 FP16 FMA3 AVX AVX2 AVX_512F AVX512_COMMON AVX512_SKX
--
-- C/C++:
-- Built as dynamic libs?: YES
-- C++ standard: 11
-- C++ Compiler: C:/Program Files/Microsoft Visual Studio/2022/Community/VC/Tools/MSVC/14.40.33807/bin/Hostx64/x64/cl.exe (ver 19.40.33811.0)
-- C++ flags (Release): /DWIN32 /D_WINDOWS /W4 /GR /D _CRT_SECURE_NO_DEPRECATE /D _CRT_NONSTDC_NO_DEPRECATE /D _SCL_SECURE_NO_WARNINGS /Gy /bigobj /Oi /fp:precise /EHa /wd4127 /wd4251 /wd4324 /wd4275 /wd4512 /wd4589 /wd4819 /MP /O2 /Ob2 /DNDEBUG
-- C++ flags (Debug): /DWIN32 /D_WINDOWS /W4 /GR /D _CRT_SECURE_NO_DEPRECATE /D _CRT_NONSTDC_NO_DEPRECATE /D _SCL_SECURE_NO_WARNINGS /Gy /bigobj /Oi /fp:precise /EHa /wd4127 /wd4251 /wd4324 /wd4275 /wd4512 /wd4589 /wd4819 /MP /Zi /Ob0 /Od /RTC1
-- C Compiler: C:/Program Files/Microsoft Visual Studio/2022/Community/VC/Tools/MSVC/14.40.33807/bin/Hostx64/x64/cl.exe
-- C flags (Release): /DWIN32 /D_WINDOWS /W3 /D _CRT_SECURE_NO_DEPRECATE /D _CRT_NONSTDC_NO_DEPRECATE /D _SCL_SECURE_NO_WARNINGS /Gy /bigobj /Oi /fp:precise /MP /O2 /Ob2 /DNDEBUG
-- C flags (Debug): /DWIN32 /D_WINDOWS /W3 /D _CRT_SECURE_NO_DEPRECATE /D _CRT_NONSTDC_NO_DEPRECATE /D _SCL_SECURE_NO_WARNINGS /Gy /bigobj /Oi /fp:precise /MP /Zi /Ob0 /Od /RTC1
-- Linker flags (Release): /machine:x64 /INCREMENTAL:NO
-- Linker flags (Debug): /machine:x64 /debug /INCREMENTAL
-- ccache: NO
-- Precompiled headers: NO
-- Extra dependencies: C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v12.5/lib/x64/cudart_static.lib C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v12.5/lib/x64/nppial.lib C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v12.5/lib/x64/nppc.lib C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v12.5/lib/x64/nppitc.lib C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v12.5/lib/x64/nppig.lib C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v12.5/lib/x64/nppist.lib C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v12.5/lib/x64/nppidei.lib C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v12.5/lib/x64/cublas.lib C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v12.5/lib/x64/cublasLt.lib C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v12.5/lib/x64/cufft.lib C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v12.5/lib/x64/nppif.lib C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v12.5/lib/x64/nppim.lib C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v12.5/lib/x64/nppicc.lib
-- 3rdparty dependencies:
--
-- OpenCV modules:
-- To be built: aruco bgsegm bioinspired calib3d ccalib core cudaarithm cudabgsegm cudacodec cudafeatures2d cudafilters cudaimgproc cudalegacy cudaobjdetect cudaoptflow cudastereo cudawarping cudev datasets dnn dnn_objdetect dnn_superres dpm face features2d flann fuzzy gapi hfs highgui img_hash imgcodecs imgproc intensity_transform line_descriptor mcc ml objdetect optflow phase_unwrapping photo plot python3 quality rapid reg rgbd saliency shape signal stereo stitching structured_light superres surface_matching text tracking ts video videoio videostab wechat_qrcode world xfeatures2d ximgproc xobjdetect xphoto
-- Disabled: -
-- Disabled by dependency: -
-- Unavailable: alphamat cannops cvv freetype hdf java julia matlab ovis python2 python2 sfm viz
-- Applications: tests perf_tests examples apps
-- Documentation: NO
-- Non-free algorithms: NO
--
-- Windows RT support: NO
--
-- GUI:
-- Win32 UI: YES
-- VTK support: NO
--
-- Media I/O:
-- ZLib: build (ver 1.3.1)
-- JPEG: build-libjpeg-turbo (ver 3.0.3-70)
-- SIMD Support Request: YES
-- SIMD Support: NO
-- WEBP: build (ver encoder: 0x020f)
-- PNG: build (ver 1.6.43)
-- SIMD Support Request: YES
-- SIMD Support: YES (Intel SSE)
-- TIFF: build (ver 42 - 4.6.0)
-- JPEG 2000: build (ver 2.5.0)
-- OpenEXR: build (ver 2.3.0)
-- HDR: YES
-- SUNRASTER: YES
-- PXM: YES
-- PFM: YES
--
-- Video I/O:
-- DC1394: NO
-- FFMPEG: YES (prebuilt binaries)
-- avcodec: YES (58.134.100)
-- avformat: YES (58.76.100)
-- avutil: YES (56.70.100)
-- swscale: YES (5.9.100)
-- avresample: YES (4.0.0)
-- GStreamer: NO
-- DirectShow: YES
-- Media Foundation: YES
-- DXVA: YES
--
-- Parallel framework: Concurrency
--
-- Trace: YES (with Intel ITT)
--
-- Other third-party libraries:
-- Intel IPP: 2021.11.0 [2021.11.0]
-- at: C:/Users/dgard/opencvGPU/build/3rdparty/ippicv/ippicv_win/icv
-- Intel IPP IW: sources (2021.11.0)
-- at: C:/Users/dgard/opencvGPU/build/3rdparty/ippicv/ippicv_win/iw
-- Lapack: NO
-- Eigen: NO
-- Custom HAL: NO
-- Protobuf: build (3.19.1)
-- Flatbuffers: builtin/3rdparty (23.5.9)
--
-- NVIDIA CUDA: YES (ver 12.5.40, CUFFT CUBLAS NVCUVID NVCUVENC)
-- NVIDIA GPU arch: 61
-- NVIDIA PTX archs:
--
-- cuDNN: YES (ver 9.1.1)
--
-- OpenCL: YES (NVD3D11)
-- Include path: C:/Users/dgard/opencvGPU/opencv/3rdparty/include/opencl/1.2
-- Link libraries: Dynamic load
--
-- Python 3:
-- Interpreter: C:/Users/dgard/anaconda3/python.exe (ver 3.11.7)
-- Libraries: C:/Users/dgard/anaconda3/libs/python311.lib (ver 3.11.7)
-- Limited API: NO
-- numpy: C:/Users/dgard/anaconda3/Lib/site-packages/numpy/core/include (ver 1.26.4)
-- install path: C:/Users/dgard/anaconda3/Lib/site-packages/cv2/python-3.11
--
-- Python (for build): C:/Users/dgard/anaconda3/python.exe
--
-- Java:
-- ant: NO
-- Java: NO
-- JNI: NO
-- Java wrappers: NO
-- Java tests: NO
--
-- Install to: C:/Users/dgard/opencvGPU/build/install
-- -----------------------------------------------------------------
--
-- Configuring done (35.9s)
-- Generating done (153.6s)
-- Build files have been written to: C:/Users/dgard/opencvGPU/build
- Run the following CMake command to build
"C:\Program Files\CMake\bin\cmake.exe" --build C:/Users/dgard/opencvGPU/build --target install --config Release
- Validate the install with
"C:\Users\dgard\opencvGPU\build\bin\Release\opencv_test_cudaarithm.exe" --gtest_filter=CUDA_Arithm/GEMM.Accuracy/0
- Attempt to import the cv2 module in an Anaconda Prompt.
Issue submission checklist
- I report the issue, it's not a question
- I checked the problem with documentation, FAQ, open issues, forum.opencv.org, Stack Overflow, etc and have not found any solution
- I updated to the latest OpenCV version and the issue is still there
- There is reproducer code and related data files (videos, images, onnx, etc)