# Compile OpenCv with Cuda

**URL:** <https://forum.opencv.org/t/compile-opencv-with-cuda/3955>\
**Category:** C++\
**Tags:** build, cuda\
**Created:** [June 21, 2021, 1:37pm UTC](https://forum.opencv.org/t/compile-opencv-with-cuda/3955 "2021-06-21T13:37:26Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Christophe\_Jacquelin](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.opencv.org/christophe_jacquelin/32/135_2.png) [@Christophe\_Jacquelin](https://forum.opencv.org/u/Christophe_Jacquelin)\
**Post date:** [June 21, 2021, 1:37pm UTC](https://forum.opencv.org/t/compile-opencv-with-cuda/3955/1 "2021-06-21T13:37:26Z")

</div>

Hello,  
It’s take about 5/6 hours to compile OpenCV with Cuda option.  
What’s happen ? could you help ?  
Thank you

---

<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:** [June 21, 2021, 1:52pm UTC](https://forum.opencv.org/t/compile-opencv-with-cuda/3955/2 "2021-06-21T13:52:34Z")

</div>

There are two main reasons for this “in general”. Either of which may or may not apply to you;

1. you are using something like Visual Studio and not ninja for compilation, and/or
2. you are compiling for all device compute capabilities.

I suspect definitely (2) if it is taking 5/6 hours. If so passing -DCUDA\_ARCH\_BIN=7.2 where 7.2 should be the compute capability of the device **you** will be running your OpenCv program on should help. This will however result in an application which **won’t** execute on devices of any other compute capability.

---

<div class="post-metadata">

**Author:** ![Christophe\_Jacquelin](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.opencv.org/christophe_jacquelin/32/135_2.png) [@Christophe\_Jacquelin](https://forum.opencv.org/u/Christophe_Jacquelin)\
**Post date:** [June 21, 2021, 2:05pm UTC](https://forum.opencv.org/t/compile-opencv-with-cuda/3955/3 "2021-06-21T14:05:59Z")

</div>

Yes I use Visual Studio 2019. and compiling for all. Thx
