# OpenCV with CuDA

**URL:** <https://forums.developer.nvidia.com/t/opencv-with-cuda/219493>\
**Category:** Jetson AGX Orin\
**Tags:** opencv, python, cuda\
**Created:** [July 1, 2022, 11:56am UTC](https://forums.developer.nvidia.com/t/opencv-with-cuda/219493 "2022-07-01T11:56:19Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![naveen.crasta](https://sea2.discourse-cdn.com/nvidia/user_avatar/forums.developer.nvidia.com/naveen.crasta/32/122562_2.png) [@naveen.crasta](https://forums.developer.nvidia.com/u/naveen.crasta)\
**Post date:** [July 1, 2022, 11:56am UTC](https://forums.developer.nvidia.com/t/opencv-with-cuda/219493/1 "2022-07-01T11:56:19Z")

</div>

Hi,

In Orin, after sudo apt install nvidia-jetpack, I tried to run cv2.cuda.getCudaEnabledDeviceCount(). It returned zero! Is the OpenCV installed with CUDA or not?

Best regards,  
Naveen

---

<div class="post-metadata">

**Author:** ![dusty\_nv](https://sea2.discourse-cdn.com/nvidia/user_avatar/forums.developer.nvidia.com/dusty_nv/32/14043_2.png) [@dusty\_nv](https://forums.developer.nvidia.com/u/dusty_nv)\
**Post date:** [July 1, 2022, 5:12pm UTC](https://forums.developer.nvidia.com/t/opencv-with-cuda/219493/2 "2022-07-01T17:12:05Z")

</div>

Hi @naveen.crasta, the pre-installed OpenCV doesn’t support CUDA. However, you can build OpenCV with CUDA/cuDNN support using the scripts from [https://github.com/mdegans/nano\_build\_opencv/](https://github.com/mdegans/nano_build_opencv/)

Or I have some pre-built OpenCV binaries with CUDA/cuDNN support that you can download from here: [OpenCV-4.5.0-aarch64.tar.gz](https://nvidia.box.com/shared/static/2hssa5g3v28ozvo3tc3qwxmn78yerca9.gz)

The steps used to install these binaries you can follow along with the script here: [https://github.com/dusty-nv/jetson-containers/blob/be0dca3d19b30e64d129c92e93425c9ede40d65f/scripts/opencv\_install.sh#L17](https://github.com/dusty-nv/jetson-containers/blob/be0dca3d19b30e64d129c92e93425c9ede40d65f/scripts/opencv_install.sh#L17)

Normally I install these binaries into container, so you can use the l4t-pytorch, l4t-tensorflow, or l4t-ml containers for JetPack 5.x (L4T R34.1.x) and they will already have OpenCV+CUDA installed.

---

<div class="post-metadata">

**Author:** ![naveen.crasta](https://sea2.discourse-cdn.com/nvidia/user_avatar/forums.developer.nvidia.com/naveen.crasta/32/122562_2.png) [@naveen.crasta](https://forums.developer.nvidia.com/u/naveen.crasta)\
**Post date:** [July 12, 2022, 9:09am UTC](https://forums.developer.nvidia.com/t/opencv-with-cuda/219493/5 "2022-07-12T09:09:29Z")

</div>

Hi @dusty_nv,  
Thanks for your reply. Do you have the script to create the DEB pkg? I would like to try to build DEB pkg in a Docker for 4.5.3.

Best regards,  
Naveen

---

<div class="post-metadata">

**Author:** ![dusty\_nv](https://sea2.discourse-cdn.com/nvidia/user_avatar/forums.developer.nvidia.com/dusty_nv/32/14043_2.png) [@dusty\_nv](https://forums.developer.nvidia.com/u/dusty_nv)\
**Post date:** [July 12, 2022, 2:22pm UTC](https://forums.developer.nvidia.com/t/opencv-with-cuda/219493/6 "2022-07-12T14:22:38Z")

</div>

Hi Naveen, if you run `make package`, then OpenCV will build the debs.

I have a Dockerfile for building the OpenCV debs here:

- [https://github.com/dusty-nv/jetson-containers/blob/master/Dockerfile.opencv](https://github.com/dusty-nv/jetson-containers/blob/master/Dockerfile.opencv)
- [https://github.com/dusty-nv/jetson-containers/blob/master/scripts/docker\_build\_opencv.sh](https://github.com/dusty-nv/jetson-containers/blob/master/scripts/docker_build_opencv.sh)

---

<div class="post-metadata">

**Author:** ![system](https://sea2.discourse-cdn.com/nvidia/user_avatar/forums.developer.nvidia.com/system/32/68080_2.png) [@system](https://forums.developer.nvidia.com/u/system)\
**Post date:** [July 26, 2022, 2:22pm UTC](https://forums.developer.nvidia.com/t/opencv-with-cuda/219493/7 "2022-07-26T14:22:59Z")

</div>

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.
