# Unable to install OpenCV 3.2 with JetPack 4.6.3 in AGX Xavier

**URL:** <https://forums.developer.nvidia.com/t/unable-to-install-opencv-3-2-with-jetpack-4-6-3-in-agx-xavier/244363>\
**Category:** Jetson AGX Xavier\
**Tags:** opencv, ros\
**Created:** [February 28, 2023, 10:42am UTC](https://forums.developer.nvidia.com/t/unable-to-install-opencv-3-2-with-jetpack-4-6-3-in-agx-xavier/244363 "2023-02-28T10:42:45Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![RaviJoshi](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@RaviJoshi](https://forums.developer.nvidia.com/u/RaviJoshi)\
**Post date:** [February 28, 2023, 10:42am UTC](https://forums.developer.nvidia.com/t/unable-to-install-opencv-3-2-with-jetpack-4-6-3-in-agx-xavier/244363/1 "2023-02-28T10:42:45Z")

</div>

I am using ROS Melodic (Ubuntu 18.04 LTS), so I used JetPack v4.6.3 to get started with the AGX Xavier device. While compiling a ROS package, I got the OpenCV mismatch error as shown below:

```auto
  CMake Error at CMakeLists.txt:31 (find_package):
    Could not find a configuration file for package "OpenCV" that is compatible
    with requested version "3".
  
    The following configuration files were considered but not accepted:
  
      /usr/lib/aarch64-linux-gnu/cmake/opencv4/OpenCVConfig.cmake, version: 4.1.1
  
  
  
  -- Configuring incomplete, errors occurred!

```

I looked at the OpenCV package installed on AGX Xavier and found two versions as shown below:

```auto
ravi@ubuntu:~/ros_ws$ dpkg -l | grep libopencv
ii libopencv 4.1.1-2-gd5a58aa75 arm64 Open Computer Vision Library
ii libopencv-calib3d3.2:arm64 3.2.0+dfsg-4ubuntu0.1 arm64 computer vision Camera Calibration library
ii libopencv-core3.2:arm64 3.2.0+dfsg-4ubuntu0.1 arm64 computer vision core library
ii libopencv-dev 4.1.1-2-gd5a58aa75 arm64 Development files for Open Source Computer Vision Library
ii libopencv-features2d3.2:arm64 3.2.0+dfsg-4ubuntu0.1 arm64 computer vision Feature Detection and Descriptor Extraction library
ii libopencv-flann3.2:arm64 3.2.0+dfsg-4ubuntu0.1 arm64 computer vision Clustering and Search in Multi-Dimensional spaces library
ii libopencv-highgui3.2:arm64 3.2.0+dfsg-4ubuntu0.1 arm64 computer vision High-level GUI and Media I/O library
ii libopencv-imgcodecs3.2:arm64 3.2.0+dfsg-4ubuntu0.1 arm64 computer vision Image Codecs library
ii libopencv-imgproc3.2:arm64 3.2.0+dfsg-4ubuntu0.1 arm64 computer vision Image Processing library
ii libopencv-ml3.2:arm64 3.2.0+dfsg-4ubuntu0.1 arm64 computer vision Machine Learning library
ii libopencv-python 4.1.1-2-gd5a58aa75 arm64 Python bindings for Open Source Computer Vision Library
ii libopencv-samples 4.1.1-2-gd5a58aa75 arm64 Samples for Open Source Computer Vision Library
ii libopencv-videoio3.2:arm64 3.2.0+dfsg-4ubuntu0.1 arm64 computer vision Video I/O library

```

You can see there are two versions, i.e., 3.2.0 installed by ROS, and 4.1.1 installed by JetPack. Therefore, in order to fix my issue, I tried installing OpenCV 3.2.0 from source. I quickly jumped into jetsonhacks/buildOpenCVXavier repository. I set the OPENCV\_VERSION=3.2.0 and executed the script. Unfortunately, the compilation did not work. Below is the errors snippet:

```auto
CMake Error: The following variables are used in this project, but they are set to NOTFOUND.
Please set them or make sure they are set and tested correctly in the CMake files:
CUDA_nppi_LIBRARY (ADVANCED)
    linked by target "opencv_cudev" in directory /home/ravi/opencv/modules/cudev
    linked by target "opencv_cudev" in directory /home/ravi/opencv/modules/cudev
    linked by target "opencv_test_cudev" in directory /home/ravi/opencv/modules/cudev/test
    linked by target "opencv_test_core" in directory /home/ravi/opencv/modules/core
    linked by target "opencv_core" in directory /home/ravi/opencv/modules/core
    linked by target "opencv_core" in directory /home/ravi/opencv/modules/core
    linked by target "opencv_perf_core" in directory /home/ravi/opencv/modules/core
...

```

The logs are really long. So [I posted them to Pastebin to keep this post shorter and cleaner](https://pastebin.com/iatCXxLx).

Any workaround, please.

Thank you

---

<div class="post-metadata">

**Author:** ![DaneLLL](https://sea2.discourse-cdn.com/nvidia/user_avatar/forums.developer.nvidia.com/danelll/32/14043_2.png) [@DaneLLL](https://forums.developer.nvidia.com/u/DaneLLL)\
**Post date:** [March 1, 2023, 2:55am UTC](https://forums.developer.nvidia.com/t/unable-to-install-opencv-3-2-with-jetpack-4-6-3-in-agx-xavier/244363/3 "2023-03-01T02:55:55Z")

</div>

Hi,  
There is a script from a contributor and yo may give it a try:  
[GitHub - mdegans/nano\_build\_opencv: Build OpenCV on Nvidia Jetson Nano](https://github.com/mdegans/nano_build_opencv)

You may also refer to:  
[https://developer.nvidia.com/blog/accelerating-ai-modules-for-ros-and-ros-2-on-jetson/](https://developer.nvidia.com/blog/accelerating-ai-modules-for-ros-and-ros-2-on-jetson/)

---

<div class="post-metadata">

**Author:** ![RaviJoshi](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@RaviJoshi](https://forums.developer.nvidia.com/u/RaviJoshi)\
**Post date:** [March 1, 2023, 3:30am UTC](https://forums.developer.nvidia.com/t/unable-to-install-opencv-3-2-with-jetpack-4-6-3-in-agx-xavier/244363/4 "2023-03-01T03:30:26Z")

</div>

Hello @DaneLLL

Thank you very much for your kind support. I tried [mdegans/nano\_build\_opencv](https://github.com/mdegans/nano_build_opencv) for installing version 3.2.0, but got exactly the same error as mentioned in my logs above.

Below is the error snippet:

```auto
CMake Error: The following variables are used in this project, but they are set to NOTFOUND.
Please set them or make sure they are set and tested correctly in the CMake files:
CUDA_nppi_LIBRARY (ADVANCED)
    linked by target "opencv_cudev" in directory /tmp/build_opencv/opencv/modules/cudev
    linked by target "opencv_cudev" in directory /tmp/build_opencv/opencv/modules/cudev
    linked by target "opencv_core" in directory /tmp/build_opencv/opencv/modules/core
    linked by target "opencv_core" in directory /tmp/build_opencv/opencv/modules/core
    linked by target "opencv_cudaarithm" in directory /tmp/build_opencv/opencv/modules/cudaarithm
    linked by target "opencv_cudaarithm" in directory /tmp/build_opencv/opencv/modules/cudaarithm
    linked by target "opencv_flann" in directory /tmp/build_opencv/opencv/modules/flann

```

Any workaround, please.

Thank you again

---

<div class="post-metadata">

**Author:** ![RaviJoshi](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@RaviJoshi](https://forums.developer.nvidia.com/u/RaviJoshi)\
**Post date:** [March 1, 2023, 3:42am UTC](https://forums.developer.nvidia.com/t/unable-to-install-opencv-3-2-with-jetpack-4-6-3-in-agx-xavier/244363/5 "2023-03-01T03:42:43Z")

</div>

Next, I tried installing OpenCV 3.4.3 as 3.2.0 failed. Unfortunately, this one showed another error `nvcc fatal : Unsupported gpu architecture 'compute_87'`. Below is more information:

```auto
/tmp/build_opencv/opencv/modules/cudalegacy/include/opencv2/cudalegacy/NCVHaarObjectDetection.hpp: In member function 'void HaarFeature64::getRect(Ncv32u*, Ncv32u*, Ncv32u*, Ncv32u*)':
/tmp/build_opencv/opencv/modules/cudalegacy/include/opencv2/cudalegacy/NCVHaarObjectDetection.hpp:102:56: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
         NcvRect8u tmpRect = *(NcvRect8u*)(&this->_ui2.x);
                                                        ^
/tmp/build_opencv/opencv/modules/cudalegacy/include/opencv2/cudalegacy/NCVHaarObjectDetection.hpp:102:56: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
[30%] Built target pch_Generate_opencv_ximgproc
[30%] Built target pch_Generate_opencv_bgsegm
[30%] Built target pch_Generate_opencv_aruco
[30%] Built target pch_Generate_opencv_xfeatures2d
[30%] Built target pch_Generate_opencv_optflow
[30%] Built target pch_Generate_opencv_stitching
Makefile:162: recipe for target 'all' failed
make: *** [all] Error 2
[1%] Built target gen-pkgconfig
[3%] Built target libjasper
[8%] Built target IlmImf
[14%] Built target libprotobuf
[17%] Built target carotene_objs
[18%] Built target tegra_hal
[18%] Built target opencv_cudev
[18%] Built target opencv_core_pch_dephelp
[18%] Built target pch_Generate_opencv_core
[18%] Building NVCC (Device) object modules/core/CMakeFiles/cuda_compile_1.dir/src/cuda/cuda_compile_1_generated_gpu_mat.cu.o
nvcc fatal : Unsupported gpu architecture 'compute_87'
CMake Error at cuda_compile_1_generated_gpu_mat.cu.o.RELEASE.cmake:221 (message):
  Error generating
  /tmp/build_opencv/opencv/build/modules/core/CMakeFiles/cuda_compile_1.dir/src/cuda/./cuda_compile_1_generated_gpu_mat.cu.o

```

---

<div class="post-metadata">

**Author:** ![DaneLLL](https://sea2.discourse-cdn.com/nvidia/user_avatar/forums.developer.nvidia.com/danelll/32/14043_2.png) [@DaneLLL](https://forums.developer.nvidia.com/u/DaneLLL)\
**Post date:** [March 1, 2023, 7:17am UTC](https://forums.developer.nvidia.com/t/unable-to-install-opencv-3-2-with-jetpack-4-6-3-in-agx-xavier/244363/6 "2023-03-01T07:17:54Z")

</div>

Hi,  
Looks like the previous version does not support Xavier GPU. We would suggest use later version of OpenCV.

For a try you can grep `compute_` to find out where the architectures are defined, and then add `compute_87`. This is not recommended but you may give it a try.

---

<div class="post-metadata">

**Author:** ![RaviJoshi](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@RaviJoshi](https://forums.developer.nvidia.com/u/RaviJoshi)\
**Post date:** [March 2, 2023, 2:30am UTC](https://forums.developer.nvidia.com/t/unable-to-install-opencv-3-2-with-jetpack-4-6-3-in-agx-xavier/244363/7 "2023-03-02T02:30:15Z")

</div>

Thank you very much.

The reason why I chose OpenCV 3.2.0 is that ROS Melodic comes with this OpenCV.

My quick solution to this problem is to remove `libopencv` first, and then install `libopencv 3.2.0` as shown below:

```auto
$ sudo apt purge --remove libopencv
$ sudo apt install libopencv-dev=3.2.0+dfsg-4ubuntu0.1

```

A consequence to this workaround is that the OpenCV 3.2.0 installed this way is CPU only. But for now ROS Melodic is working fine!

---

<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:** [March 21, 2023, 6:11am UTC](https://forums.developer.nvidia.com/t/unable-to-install-opencv-3-2-with-jetpack-4-6-3-in-agx-xavier/244363/9 "2023-03-21T06:11:10Z")

</div>

Closed on March 21, 2023, 6:11am UTC

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