Ask Your Question

Compile OpenCV 3.4 and Cuda 9 with MS VS15 2017

asked 2018-05-26 05:26:43 -0600

giulioaur gravatar image

I need to do fast image processing so I decide to go for OpenCV with CUDA support. Now I'm trying to build OpenCV as dll to use it in my project, but I am not even able to generate the VS project since CMake keeps giving me this error:


I am on Windows 10, CMake 3.11 with VS 15 2017 x64 generator, OpenCV 3.4 (the last release).

I have installed CUDA 9.2, 9.1 and 8.0 and set CUDA_HOME environment variable as the CUDA toolkit directory. Nothing seems to work.

Then I try to set the variable CUDA_SDK_ROOT_DIR through the CMake GUI, but the CUDA toolkit directory seems to be not the right one and I'm not able to find the CUDA sample directory anywhere.

I have googled a lot, but I found nothing that had been able to help me. Did someone face this very same issue? How can I solve it?

PS: I have successfully created the dll with TBB and IPP (without CUDA) and it is still not fast enough, so I really need to use Cuda.

edit retag flag offensive close merge delete


What version of Visual Studio are you using? 15.6 is the last one supported by CUDA 9.2. P.S.: next time do not put you an image, it cannot be indexed. Use plain text.

lezan gravatar imagelezan ( 2018-05-27 06:06:06 -0600 )edit

Yeah sorry for the image, I will substitute it with plain text as soon as I will put my hand again on that project. I was using the 15.7, do you think could be a VS problem? I think that the problem is in the CMake file that wants this Cuda SDK folder that doesn't exist.

giulioaur gravatar imagegiulioaur ( 2018-05-28 08:45:00 -0600 )edit

As reported here Visual Studio 15.6 is the last one supported for CUDA 9.2. If you want to run (compile etc) CUDA with your version, you need to downgrade your toolchain. Moreover, I am not sure that error reported is connected to this mismatch.

lezan gravatar imagelezan ( 2018-05-28 19:12:32 -0600 )edit

I'll try and I will let you know. Thanks for answer =)

giulioaur gravatar imagegiulioaur ( 2018-05-30 04:52:05 -0600 )edit

1 answer

Sort by ยป oldest newest most voted

answered 2018-05-31 05:02:42 -0600

That does not look like the normal error when you have an incompatible version of VS. CMake usually creates the solution but the build fails with reference to cl.exe.

When you have a compatible version of VS installed I would try the following guide

edit flag offensive delete link more


Now I can't try, but once I'll do it, I will mark your answer if it works.Thank you :)

giulioaur gravatar imagegiulioaur ( 2018-06-01 05:20:33 -0600 )edit

At the end, the problem was I had a "wrong" installation of Cuda 9.1 due to some problems with Visual Studio integration. Once I reinstall CUDA without it, all seem to work.

giulioaur gravatar imagegiulioaur ( 2018-06-05 11:41:42 -0600 )edit

Question Tools

1 follower


Asked: 2018-05-26 05:26:43 -0600

Seen: 1,795 times

Last updated: May 31 '18