I am runnung Visual Stadio2010, and have build the OpenCV2.4 with Cmake2.8, during the confugration have set :
WITH_CUDA flag on
CUDA_SDK_ROOT_DIR :C:/ProgramData/NVIDIA Corporation/NVIDIA GPU Computing SDK 4.2
CUDA_TOOLKIT_ROOT_DIR: C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v4.2
and then build the whole project in visual studio, successfully.
I am using NVIDIA Quadro 5000, and have tested the examples in "OpenCV-2.4.0-GPU-demos-pack-win32", which all of the works without any error.
also the core and highgui libraries function works fine too.but I cant run anything related to GPU functions in openCV.
this code return me 0 which according to documentation means no device has been find:
int deviceCount =cv::gpu::getCudaEnabledDeviceCount();
std::cout << "index " << deviceCount <<"\n";
which the same as device number number from the GPUdemopack examples, but any other gpu function shows me the following error:
OpenCV Error: No GPU support in unknown function file c:\slave\wininstallerMegaPack\src\opencv\modules\core\src\gpumat.cpp,line193
any body has any idea? please let me know. Thanks
OpenCV 2.4 is still in beta and is not ready to be used for serious projects. It has several build problems on Windows and Mac OS X as far as I could test.
I suggest you stick with the 2.3.1 which is the last stable release. Don't use the 2.4 unless there's a feature in there that you really really need.
EDIT:
By the way, OpenCV 2.3.1 only supports CUDA 4.0.
Run devicequery.exe from the Cuda SDK ( CUDA sdk 4.1\C\bin\win32\Release ) and check the compute capability value of your card.
Then in cmake for opencv, check the CUDA_ARCH_BIN includes this value.
Earlier cards only did 1.1 and don't have ARCH_PTX (the new CUDA binary format) - it's possible to make opencv build only for the new format - which doesn't need as much runtime compilation
You are saying that you had build OpenCV yourself, but the file path from error message (c:\slave\wininstallerMegaPack\...) clearly indicates that you are using prebuilt OpenCV from sourceforge. If you have really build OpenCV yourself, then you have to troubleshoot your environment and find why wrong binaries are used. (The simplest thing you can do - remove any OpenCV binaries from your PC and make a clean full build of both OpenCV and your app.)
OpenCV 2.4 betas have a packaging bug making gpu-enabled binaries useless. So you have to rebuild the library from source or use OpenCV 2.3.1 (CUDA 4.0 indeed).
GPU demos pack is tricky - it has own copy of all binaries it might need. However it can not be used for development.
Final OpenCV 2.4 release is awaited in few days. Windows package will include working CUDA binaries.
EDIT:
OpenCV 2.4.0 is out!
Related
I am having problems with OpenCV as I need to use SURF on my C++ Visual Studio 2015 project but apparently is not part of OpenCV 2.4.13 and needs to be downloaded separately.
What I specifically need is this package:
"opencv2/nonfree"
I've been looking over the Internet but I could not find anything, just a few tutorials for Ubuntu.
Does anyone know how to add these modules to the Windows version?
Thank you in advance for your time.
I'm trying to build a simple application with CUDA and I've been trying for hours on end and I just can't make it work on windows. nvcc absolutely refuses to compile without Visual Studio's compiler which doesn't support things I need. I tried building using nvcc with clang but It just asks me to use Visual Studio's compiler. I've also tried using clang directly since it now supports CUDA but I receive this error:
clang++.exe: error: Unsupported CUDA gpu architecture: compute_52
This makes no sense to me because I have the CUDA toolkit version 7.5 and my graphics card is a GTX 970 (two of them). I have googled this extensively and everywhere I come across the error the person always has is their CUDA toolkit is < 7.5. I'm on the brink of tears right now trying to get something as simple as VLA to work on this CUDA application and I just can't achieve it...
The CUDA windows toolchain requires the Visual Studio C++ compiler. You cannot use anything else on that platform. If the VS compiler doesn't support the language features you need within CUDA host code, you have no choice but to change platforms, or your expectations.
You can still potentially compile non-CUDA host code using another compiler and then link that code using NVCC and the VS toolchain.
Try to use clang-cl, --cubin=clang-cl.exe
It may be worth to work on a Linux VM or WSL2 within windows. As per the CUDA docs.
To compile new CUDA applications, a CUDA Toolkit for Linux x86 is
needed. CUDA Toolkit support for WSL is still in preview stage as
developer tools such as profilers are not available yet. However, CUDA
application development is fully supported in the WSL2 environment, as
a result, users should be able to compile new CUDA Linux applications
with the latest CUDA Toolkit for x86 Linux.
https://docs.nvidia.com/cuda/wsl-user-guide/index.html#:~:text=However%2C%20CUDA%20application%20development%20is,becomes%20available%20within%20WSL%202.
I am using Nvidia GPU Computing toolkit on Windows 7 x64 with the 64 bit Cygwin package and Eclipse. (I use the internal build tools because GNU make doesn't lik colons in Windows paths.) My code:
Here's the fairly basic piece of code:
#include
#include
using namespace std;
int main() {
cl_int error = 42;
cl_platform_id platform;
error = clGetPlatformIDs(1, &platform, NULL);
return 0;
}
C++ code both compiles and runs fine, and I can use OpenCL headers and cl_int and cl_device_id, but with clGetPlatformID I get the following compile error:
relocation truncated to fit: R_X86_64_32 against symbol
'__imp_clGetPlatformIDs' defined in .idata$5 section in
C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v6.0\lib
\x64/OpenCL.lib(OpenCL.dll.b)
I have tried the following:
Uninstall/reinstall Cygwin tools
Uninstall/reinstall both 32 and 64 bit libraries in the Nvidia GPU Computing toolkit
Uninstall/reinstall Eclipse and checked most settings
Avoiding 32 bit memory restrictions by adding "-mcmodel=medium" or "-mcmodel=large". (According to searches, at some point 32 and 64 bit binaries are being mixed.)
Confirmed that I am only using 64 bit Nvidia libraries and Cygwin tools.
My guess is that the internal builder is to blame, but using it was the solution to another problem that caused the build to fail.
I've got a bit of an update on this:
Wiped and re-installed pretty much everything (CUDA toolkit, Cygwin, Eclipse) and it still gives me the same error even with the appropriate flags (which I used before Captain Obvious linked to a post suggesting it).
The progress I've made is that I've probably zeroed in on where the problem actually lies. Using relative paths solved the issues with GNU make not being able to deal with colons in paths. This basically clears the Eclipse internal builder. However I've got almost the exact same setup working on another machine, the differences being that this setup has an AMD card and thus uses the AMD App SDK rather than Nvidia's OpenCL toolkit.
My suspicion is that this might be a bug brought on by the recent released version 6.0 of the CUDA toolkit as it introduces some pretty major upgrades like unified memory and they might not have tested it so well without the NSight Visual Studio-plugin. After all they do recommend that you develop using Visual Studio with that plugin and I don't have (legal) access to Visual Studio right now.
Edit: I've pretty now much confirmed it... Installed the AMD App SDK on the Nvidia GPU machine and it runs flawlessly, so seems like Nvidia has actually fucked up OpenCL in version 6 of the CUDA Toolkit. Thou knowing that they're in competition with OpenCL trough CUDA i hardly find this surprising.
I had the same error, finally I have solved this problem and the latest what I have done is:
1) In cygwin install all packages containing opencl in name.
2) Next, in ...\cygwin\etc\OpenCL\vendors\ (I have found pocl.icd there) create nvidia.icd and place there one string "/cygdrive/c/Windows/System32/nvopencl.dll". The similar actions can be done for Intel OpenCL driver.
3) Finally do not make mistakes (as I did) in CMake file. Example of working code:
cmake_minimum_required(VERSION 3.6)
set(MODULE_NAME opencl-test)
project(${MODULE_NAME})
set(CMAKE_CXX_STANDARD 14)
find_package(OpenCL)
# set include directories
include_directories(${OpenCL_INCLUDE_DIRS})
# set source files
set(SOURCE_FILES main.cpp)
add_executable(${MODULE_NAME} ${SOURCE_FILES})
# linking
target_link_libraries(${MODULE_NAME} ${OpenCL_LIBRARY})
I tried to install cuda toolkit without display driver in CentOS 6. It gets installed properly. I was able to compile but it is compiling without performing any operation and I get garbage values in array addition. For cudaGetDeviceCount(&count) I am getting value as "o" which means I don't have any card on my machine.
You can install the CUDA toolkit without installing the driver.
You can then compile CUDA codes that use the runtime API.
You will not be able to run those codes unless you have a proper CUDA driver and GPU installed in the machine, however.
Codes that depend on the driver API will also not be compilable in this configuration, on older CUDA toolkits, without additional work. Newer CUDA toolkits provide stub libraries for driver libraries, which can be linked against.
This answer covers the method to install the CUDA toolkit without the driver.
If you want just run the codes and profiling the performance and other parameters, it would be helpful if you install GPGPU-sim simulator. It doesn't need any graphic card on your machine.
After big struggle with me and OpenCV I finally found this tutorial:
OpenCV with MinGW on Eclipse Tutorial (Scroll to "OpenCV - with CMake & MinGW")
I did everything as it has been written, but everytime I try to launch application it stops to respond just after few seconds and Windows alert communicate is shown. I noticed, that I can freely run standard C++ programs and include headfiles, but after single line of OpenCV code it fails to work properly. Also there is no information about error.
why don't you try the official tutorial http://docs.opencv.org/doc/tutorials/introduction/linux_eclipse/linux_eclipse.html#linux-eclipse-usage
this is the official site in opencv documentation which should get you started, it includes tutorials to get you started on lots of other platforms
http://docs.opencv.org/doc/tutorials/introduction/table_of_content_introduction/table_of_content_introduction.html#table-of-content-introduction
I also had a touch time getting OpenCV running but finally I found something that worked (I use Qt Creator as my IDE, not Eclipse, but maybe the problem and solution is similar).
At first I tried to download OpenCV 2.4.8, but I found it didn't include any MinGW binaries. I followed a forum on the web and installed CMake, but it seemed like OpenCV 2.4.8 didn't contain the CMake target for MinGW. After reading some more forums, I downloaded OpenCV 2.4.3 and was able to use CMake along with MinGW 4.8 (version that came with Qt 5.2) to build OpenCV. This got me to a point where I could compile my programs and attempt to run them. Some of the pure c commands even worked like cvLoadImage, but any of the c++ commands like imread or Mat::zeros(3,3, CV_8UC1) would cause a crash.
I tried building openCV a few more times with different options. Some sites suggested turning off SSE and SSE2 or building the debug version, but none of this worked for me.
Finally I ended up downloading TDM-GCC-32. I downloaded the on demand installer and made sure to get the dw2 version of the compiler (since a while ago I spent some time dealing with dw2 vs sjlj incompatibilities). Finally I rebuilt OpenCV with the TDM-GCC and also set TDM-GCC as the compiler in Qt Creator. This ended up being the fix.
I think there are some incompatibilities between the reference counting / allocation code used by the OpenCV Mat type and some versions of MinGW. I say this because all my crashes seemed to come from sections of code using the openCV matrix. (It seemed like it wasn't properly initialized or something). Switching to the TDM-GCC compiler fixed the problem.