# Issue while compiling opencv with cuda enabled

**URL:** <https://forum.opencv.org/t/issue-while-compiling-opencv-with-cuda-enabled/12660>\
**Category:** Uncategorized\
**Tags:** dnn, windows, build, cuda\
**Created:** [April 4, 2023, 6:53am UTC](https://forum.opencv.org/t/issue-while-compiling-opencv-with-cuda-enabled/12660 "2023-04-04T06:53:59Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![CAPED\_CRUSADER01](https://avatars.discourse-cdn.com/v4/letter/c/76d3ee/32.png) [@CAPED\_CRUSADER01](https://forum.opencv.org/u/CAPED_CRUSADER01)\
**Post date:** [April 4, 2023, 6:53am UTC](https://forum.opencv.org/t/issue-while-compiling-opencv-with-cuda-enabled/12660/1 "2023-04-04T06:53:59Z")

</div>

Hi  
I’m compiling opencv with cuda enabled for gpu acceleration. I installed cuda stuff, I have anaconda already installed, installed vs2022 with c++ and build tools. After using generate in cmake-gui, I recieved an error(Error 1: OpenCV does not recognize MSVC\_VERSION 1924). I proceeded regardless and tried to build in vs2022 but its failing with most of the issues relating to syntax errors. Can someone guide me in the right direction?  
OS: Windows 11 22H2  
Conda Python: 3.9  
Cmake: 3.26  
Visual studio: 2022  
cmake logs: [cmake\_logs.txt - Google Drive](https://drive.google.com/file/d/15_1AOHYo94nHnpus1rys57yy9ivfdIYX/view?usp=sharing)  
vs logs: [logs.txt - Google Drive](https://drive.google.com/file/d/1XAs5U1oO1r110hne_3IhalHDCTjA03kF/view?usp=share_link)

---

<div class="post-metadata">

**Author:** ![cudawarped](https://avatars.discourse-cdn.com/v4/letter/c/9dc877/32.png) [@cudawarped](https://forum.opencv.org/u/cudawarped)\
**Post date:** [April 4, 2023, 8:35am UTC](https://forum.opencv.org/t/issue-while-compiling-opencv-with-cuda-enabled/12660/2 "2023-04-04T08:35:33Z")

</div>

This doesn’t look like it has anything to do with CUDA being enabled.

OpenCV 4.5.2 was released before Visual Studio 2022 (vc17)

> <https://github.com/opencv/opencv/blob/69357b1e88680658a07cffde7678a4d697469f03/cmake/OpenCVDetectCXXCompiler.cmake#L172>

Try using OpenCV \>= 4.54

> <https://github.com/opencv/opencv/blob/4223495e6cd67011f86b8ecd9be1fa105018f3b1/cmake/OpenCVDetectCXXCompiler.cmake#L174>

after cleaning your build directory to see if this resolves your issue.

---

<div class="post-metadata">

**Author:** ![crackwitz](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.opencv.org/crackwitz/32/14_2.png) [@crackwitz](https://forum.opencv.org/u/crackwitz)\
**Post date:** [April 4, 2023, 9:47am UTC](https://forum.opencv.org/t/issue-while-compiling-opencv-with-cuda-enabled/12660/3 "2023-04-04T09:47:16Z")

</div>

[crosspost](https://meta.stackoverflow.com/a/266159):

> <https://stackoverflow.com/questions/75926898/trying-to-compile-opencv-with-cuda-on-windows>
