Ask Your Question
2

CUDA on Visual Studio 2010: To build libraries or not?

asked 2012-11-06 07:09:36 -0600

ubehagelig gravatar image

updated 2012-11-09 07:46:50 -0600

I am trying to do something really, really simple: Get CUDA to work on Visual Studio 2010 Express.

I have tried SO MANY things now that it is not even funny, and whenever I venture down a new path I eventually end up at a non-working dead-end.

All I want to know is: (A) Do I have to build the libraries with CMake or (B) can I simply use the libraries supplied with "OpenCV-2.4.3.exe"?

If the answer is (A):

  1. Do I have to download the latest version off of GIT repositories or will the files in OpenCV-2.4.3.exe be sufficient?
  2. I followed this guide and to my great joy there were no real errors. I got all the way down to setting up a property sheet. However, when I had to set up VS2010 the .lib files had not been created with a Debug and Release version. So I stopped. And cried. What do I have to do to create both Debug and Release version of the .lib files? What am I doing wrong? Am I really such a bad person? I need a hug :(

If the answer is (B):

  1. Woohoo, great! That means I can say goodbye to CMake and whathaveyou. But how exactly do I set up VS2010 so that GPU code will work on it? What do I have to refer to where? I have followed guides before on how to set up OpenCV, so it's not that I am too lazy to perform a google search. I have just done exactly what the guides say, and "regular" OpenCV works fine. But GPU doesn't. So I am thinking it must be because I am doing something wrong. Anyone with a working VS2010 (or 2008 for that matter) with GPU please share your settings.

Thank you all in advance!

These are my software and hardware credentials (if anyone need them): Windows 7 32-bit, CUDA Toolkit and SDK 4.2, OpenCV 2.4.3, Visual Studio 2010 Express (I have Visual Studio 2008 as well), CMake 2.8.10, nVidia Quadro 1000M with driver 301.27.

EDIT: I got it to work! Check out this thread: http://stackoverflow.com/questions/13228762/opencv-2-4-3rc-and-cuda-4-2-opencv-error-no-gpu-support/13231205#13231205

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
2

answered 2012-11-06 07:55:53 -0600

Vladislav Vinogradov gravatar image

updated 2012-11-06 07:56:42 -0600

The answer is B.

Look in <opencv folder>/build/gpu/<archticture>/vc10 folder. There are opencv_core and opencv_gpu modules libraries built with CUDA support.

Configure Visual Studio to use libraries for core and gpu modules from this folder instead of <opencv folder>/build/<archticture>/vc10 or copy this libraries from gpu folder to <opencv folder>/build/<archticture>/vc10 with replace.

edit flag offensive delete link more

Comments

1

I have the same issue. I configured VS to point to the GPU modules but getCudaEnabledDeviceCount always returns zero. Is there some path variable that also has to be set? Any help appreciated.

pistorinoj gravatar imagepistorinoj ( 2012-11-08 21:10:02 -0600 )edit
1

It seems like OS loads incorrect dlls (without CUDA support) wnen application start. Try to copy opencv_core.dll and opencv_gpu.dll from <opencv folder>/build/gpu/<archticture>/vc10 to your application's folder. Check enviroment PATH variable. It should contain <opencv folder>/build/gpu/<archticture>/vc10 before <opencv folder>/build/<archticture>/vc10.

Vladislav Vinogradov gravatar imageVladislav Vinogradov ( 2012-11-09 02:05:44 -0600 )edit

Thank you so much for your help. It isn't quite working yet, but I am triple-checking settings at this point, so I'll return with an update later today.

ubehagelig gravatar imageubehagelig ( 2012-11-09 03:59:33 -0600 )edit
1

Changing the PATH variable does not seem to help. Moving the opencv_core.dll and opencv_gpu.dll to the application folder does. However, then application will not run and is giving an error saying that it cannot find cudart32_42_9.dll. I would move this dll to the application folder except: 1) the current version of CUDA is 5.0; and 2) this appears to be a 32 bit version when everything else is a 64 bit version.

pistorinoj gravatar imagepistorinoj ( 2012-11-09 06:09:27 -0600 )edit
1

It means that OpenCV was compiled with CUDA 4.2. So you should use libraries from CUDA 4.2 toolkit (not only cudart, but cublas, cufft and npp too). If you want to use CUDA 5.0 you have to build OpenCV from sources.

Vladislav Vinogradov gravatar imageVladislav Vinogradov ( 2012-11-09 06:53:47 -0600 )edit
1

I checked dependecies of opencv_gpu.dll from .../build/gpu/x64/vc10. It depends from cudart64_42_9.dll. Check your project settings for 32 bit vs 64 bit paths.

Vladislav Vinogradov gravatar imageVladislav Vinogradov ( 2012-11-09 07:10:49 -0600 )edit

It's working now! You were right all along, Vladislav. Thank you so much for helping out. I appreciate it immensely. Anyone else who is trying to get CUDA to work on VS2010: Check out my edit in the original post for a guide.

ubehagelig gravatar imageubehagelig ( 2012-11-09 07:54:05 -0600 )edit

Question Tools

Stats

Asked: 2012-11-06 07:09:36 -0600

Seen: 3,259 times

Last updated: Nov 09 '12