正如问题标题所述,我正在尝试在Windows 10上为Python3 OpenCV库编译自己的二进制文件,并支持CUDA和contrib文件。
我一直关注this guide在Windows上与this one同时安装OpenCV 3,以便用CUDA支持编译OpenCV。这个问题类似于another question,但我使用的是VS2015,并且发布的解决方案并没有解决我的问题。
问题
我能够成功地遵循这些指南并使用CMake(使用GUI)进行配置,生成和构建。但是,当我在此之后从一个新终端运行Python时,我遇到了我之前链接的另一个问题中提到的相同问题。我已尝试根据此解决方案设置路径变量,但问题仍然存在。那是我在CMake输出中注意到这一行的时候:
看起来好像CMake无法找到Python库,尽管已按照安装指南的步骤5.2手动设置它们:
我不明白CMake是如何运作的,我现在对如何解决这个问题感到茫然。有关安装OpenCV的其他stackoverflow问题涉及不同版本,不同操作系统或非GPU支持。
问题
如何让CMake正确安装具有CUDA支持的OpenCV,以便我的Python3解释器可以运行它?
相关信息
系统:Windows 10 Pro(64位)
CUDA工具包版本:9.1
Python版本:3.6.1(Anaconda 4.4.0 64位)
GPU:NVIDIA GeForce GTX 1080
CMake版本:3.10.2
Visual Studio版本:14(VS2015 Win64)
这里是CMake的整个输出:
Selecting Windows SDK version 10.0.15063.0 to target Windows 10.0.16299.
found Intel IPP (ICV version): 2017.0.3 [2017.0.3]
at: C:/opencv_3.0/opencv-3.3.1/build/3rdparty/ippicv/ippicv_win
found Intel IPP IW sources: 2017.0.3
at: C:/opencv_3.0/opencv-3.3.1/build/3rdparty/ippicv/ippiw_win
CUDA detected: 9.1
CUDA NVCC target flags: -gencode;arch=compute_30,code=sm_30;-gencode;arch=compute_35,code=sm_35;-gencode;arch=compute_37,code=sm_37;-gencode;arch=compute_50,code=sm_50;-gencode;arch=compute_52,code=sm_52;-gencode;arch=compute_60,code=sm_60;-gencode;arch=compute_61,code=sm_61;-gencode;arch=compute_70,code=sm_70;-D_FORCE_INLINES
Could not find OpenBLAS include. Turning OpenBLAS_FOUND off
Could not find OpenBLAS lib. Turning OpenBLAS_FOUND off
A library with BLAS API not found. Please specify library location.
LAPACK requires BLAS
A library with LAPACK API not found. Please specify library location.
Could NOT find Doxygen (missing: DOXYGEN_EXECUTABLE)
Could NOT find JNI (missing: JAVA_AWT_LIBRARY JAVA_JVM_LIBRARY JAVA_INCLUDE_PATH JAVA_INCLUDE_PATH2 JAVA_AWT_INCLUDE_PATH)
Could NOT find Matlab (missing: MATLAB_MEX_SCRIPT MATLAB_INCLUDE_DIRS MATLAB_ROOT_DIR MATLAB_LIBRARIES MATLAB_LIBRARY_DIRS MATLAB_MEXEXT MATLAB_ARCH MATLAB_BIN)
VTK is not found. Please set -DVTK_DIR in CMake to VTK build directory, or to VTK install subdirectory with VTKConfig.cmake file
Caffe: NO
Protobuf: NO
Glog: NO
Looking for tiny_dnn.h
Looking for tiny_dnn.h - found
Found tiny-dnn in: C:/opencv_3.0/opencv-3.3.1/build/3rdparty/tinydnn/tiny-dnn-1.0.0a3
The protocol buffer compiler is not found (PROTOBUF_PROTOC_EXECUTABLE='')
freetype2: NO
harfbuzz: NO
No preference for use of exported gflags CMake configuration set, and no hints for include/library directories provided. Defaulting to preferring an installed/exported gflags CMake configuration if available.
Failed to find installed gflags CMake configuration, searching for gflags build directories exported with CMake.
Failed to find gflags - Failed to find an installed/exported CMake configuration for gflags, will perform search for installed gflags components.
Failed to find gflags - Could not find gflags include directory, set GFLAGS_INCLUDE_DIR to directory containing gflags/gflags.h
Failed to find glog - Could not find glog include directory, set GLOG_INCLUDE_DIR to directory containing glog/logging.h
Module opencv_sfm disabled because the following dependencies are not found: Eigen Glog/Gflags
Excluding from source files list: C:/opencv_3.0/opencv-3.3.1/build/modules/imgproc/accum.neon.cpp
Torch importer has been enabled. To run the tests you have to install Torch ('th' executable should be available) and generate testdata using opencv_extra/testdata/dnn/generate_torch_models.py script.
Tesseract: NO
DNN_FACE_DETECTOR: Download: res10_300x300_ssd_iter_140000.caffemodel
Pylint: registered 110 targets. Build 'check_pylint' target to run checks ("cmake --build . --target check_pylint" or "make check_pylint")
General configuration for OpenCV 3.3.1 =====================================
Version control: unknown
Extra modules:
Location (extra): C:/opencv_3.0/opencv_contrib-3.3.1/modules
Version control (extra): unknown
Platform:
Timestamp: 2018-02-02T20:23:50Z
Host: Windows 10.0.16299 AMD64
CMake: 3.10.2
CMake generator: Visual Studio 14 2015 Win64
CMake build tool: C:/Program Files (x86)/MSBuild/14.0/bin/MSBuild.exe
MSVC: 1900
CPU/HW features:
Baseline: SSE SSE2 SSE3
requested: SSE3
Dispatched code generation: SSE4_1 SSE4_2 FP16 AVX AVX2
requested: SSE4_1 SSE4_2 AVX FP16 AVX2
SSE4_1 (3 files): + SSSE3 SSE4_1
SSE4_2 (1 files): + SSSE3 SSE4_1 POPCNT SSE4_2
FP16 (2 files): + SSSE3 SSE4_1 POPCNT SSE4_2 FP16 AVX
AVX (5 files): + SSSE3 SSE4_1 POPCNT SSE4_2 AVX
AVX2 (8 files): + SSSE3 SSE4_1 POPCNT SSE4_2 FP16 FMA3 AVX AVX2
C/C++:
Built as dynamic libs?: YES
C++11: YES
C++ Compiler: C:/Program Files (x86)/Microsoft Visual Studio 14.0/VC/bin/x86_amd64/cl.exe (ver 19.0.24215.1)
C++ flags (Release): /DWIN32 /D_WINDOWS /W4 /GR /EHa /D _CRT_SECURE_NO_DEPRECATE /D _CRT_NONSTDC_NO_DEPRECATE /D _SCL_SECURE_NO_WARNINGS /Gy /bigobj /Oi /wd4251 /wd4324 /wd4275 /wd4512 /wd4589 /MP12 /MD /O2 /Ob2 /DNDEBUG /Zi
C++ flags (Debug): /DWIN32 /D_WINDOWS /W4 /GR /EHa /D _CRT_SECURE_NO_DEPRECATE /D _CRT_NONSTDC_NO_DEPRECATE /D _SCL_SECURE_NO_WARNINGS /Gy /bigobj /Oi /wd4251 /wd4324 /wd4275 /wd4512 /wd4589 /MP12 /MDd /Zi /Ob0 /Od /RTC1
C Compiler: C:/Program Files (x86)/Microsoft Visual Studio 14.0/VC/bin/x86_amd64/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 /MP12 /MD /O2 /Ob2 /DNDEBUG /Zi
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 /MP12 /MDd /Zi /Ob0 /Od /RTC1
Linker flags (Release): /machine:x64 /INCREMENTAL:NO /debug
Linker flags (Debug): /machine:x64 /debug /INCREMENTAL
ccache: NO
Precompiled headers: YES
Extra dependencies: cudart.lib nppc.lib nppial.lib nppicc.lib nppicom.lib nppidei.lib nppif.lib nppig.lib nppim.lib nppist.lib nppisu.lib nppitc.lib npps.lib cublas.lib cufft.lib -LIBPATH:C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v9.1/lib/x64
3rdparty dependencies:
OpenCV modules:
To be built: cudev core cudaarithm flann imgproc ml objdetect phase_unwrapping plot reg surface_matching video xphoto bgsegm cudabgsegm cudafilters cudaimgproc cudawarping dnn face fuzzy img_hash imgcodecs photo shape videoio xobjdetect cudacodec highgui ts bioinspired dpm features2d line_descriptor text calib3d ccalib cudafeatures2d cudalegacy cudaobjdetect cudaoptflow cudastereo datasets rgbd stereo structured_light superres tracking videostab xfeatures2d ximgproc aruco optflow stitching
Disabled: js world contrib_world saliency
Disabled by dependency: -
Unavailable: java python2 python3 viz cnn_3dobj cvv dnn_modern freetype hdf matlab sfm
Windows RT support: NO
GUI:
QT: NO
Win32 UI: YES
OpenGL support: NO
VTK support: NO
Media I/O:
ZLib: build (ver 1.2.8)
JPEG: build (ver 90)
WEBP: build (ver encoder: 0x020e)
PNG: build (ver 1.6.24)
TIFF: build (ver 42 - 4.0.2)
JPEG 2000: build (ver 1.900.1)
OpenEXR: build (ver 1.7.1)
GDAL: NO
GDCM: NO
Video I/O:
Video for Windows: YES
DC1394 1.x: NO
DC1394 2.x: NO
FFMPEG: YES (prebuilt binaries)
avcodec: YES (ver 57.89.100)
avformat: YES (ver 57.71.100)
avutil: YES (ver 55.58.100)
swscale: YES (ver 4.6.100)
avresample: YES (ver 3.5.0)
GStreamer: NO
OpenNI: NO
OpenNI PrimeSensor Modules: NO
OpenNI2: NO
PvAPI: NO
GigEVisionSDK: NO
DirectShow: YES
Media Foundation: NO
XIMEA: NO
Intel PerC: NO
Intel Media SDK: NO
Parallel framework: Concurrency
Trace: YES (with Intel ITT)
Other third-party libraries:
Use Intel IPP: 2017.0.3 [2017.0.3]
at: C:/opencv_3.0/opencv-3.3.1/build/3rdparty/ippicv/ippicv_win
Use Intel IPP IW: sources (2017.0.3)
at: C:/opencv_3.0/opencv-3.3.1/build/3rdparty/ippicv/ippiw_win
Use Lapack: NO
Use Eigen: NO
Use Cuda: YES (ver 9.1)
Use OpenCL: YES
Use OpenVX: NO
Use custom HAL: NO
NVIDIA CUDA
Use CUFFT: YES
Use CUBLAS: YES
USE NVCUVID: YES
NVIDIA GPU arch: 30 35 37 50 52 60 61 70
NVIDIA PTX archs:
Use fast math: YES
OpenCL: <Dynamic loading of OpenCL library>
Include path: C:/opencv_3.0/opencv-3.3.1/3rdparty/include/opencl/1.2
Use AMDFFT: NO
Use AMDBLAS: NO
Python 2:
Interpreter: NO
Python 3:
Interpreter: C:/Program Files/Anaconda3/python.exe (ver 3.6.1)
Python (for build): C:/Program Files/Anaconda3/python.exe
Pylint: C:/Program Files/Anaconda3/Scripts/pylint.exe (ver: 1.6.4, checks: 110)
Java:
ant: NO
JNI: NO
Java wrappers: NO
Java tests: NO
Matlab: Matlab not found or implicitly disabled
Documentation:
Doxygen: NO
Tests and samples:
Tests: YES
Performance tests: YES
C/C++ Examples: YES
Install path: C:/opencv_3.0/opencv-3.3.1/build/install
cvconfig.h is in: C:/opencv_3.0/opencv-3.3.1/build
-----------------------------------------------------------------
Configuring done
Generating done
答案 0 :(得分:2)
如果您正确地遵循指南,则不会显示此错误。有时可能无法正确设置Windows注册表项。 This post用于检查您的注册表项是否设置正确。
更改注册表项后,删除opencv目录中的所有cmake文件,重新启动cmake GUI并再次按照指南操作。您也可以使用this guide,这就是我使用的内容。