Caffe Compilation on Jetson Xavier NX

I am using this forum How to Install Caffe and PyCaffe on Jetson TX2 to compile caffe on jetson xavier nx. When I run make -j4 all command I am getting this error
fatal error: opencv2/core/core.hpp: No such file or directory
#include <opencv2/core/core.hpp>

What I do not understand that I have open CV 4.1.1 installed ?

Also I have run commands regarding open cv to try removing any dependencies but still getting this error.

Hi,

We can build it with the following command.
Please give it a try.

$ sudo apt-get install libboost-dev libboost-all-dev
$ sudo apt-get install libgflags-dev libgoogle-glog-dev liblmdb-dev libatlas-base-dev liblmdb-dev libblas-dev libatlas-base-dev libprotobuf-dev libleveldb-dev libsnappy-dev libhdf5-serial-dev protobuf-compiler
$ git clone https://github.com/BVLC/caffe
$ cd caffe/

Apply following patch:

diff --git a/Makefile b/Makefile
index b7660e85..14538a38 100644
--- a/Makefile
+++ b/Makefile
@@ -178,7 +178,7 @@ ifneq ($(CPU_ONLY), 1)
        LIBRARIES := cudart cublas curand
 endif

-LIBRARIES += glog gflags protobuf boost_system boost_filesystem m
+LIBRARIES += glog gflags protobuf boost_system boost_filesystem m hdf5_serial_hl hdf5_serial

 # handle IO dependencies
 USE_LEVELDB ?= 1
diff --git a/Makefile.config.example b/Makefile.config.example
index 24ca6327..28b4b9b1 100644
--- a/Makefile.config.example
+++ b/Makefile.config.example
@@ -2,13 +2,13 @@
 # Contributions simplifying and improving our build system are welcome!

 # cuDNN acceleration switch (uncomment to build with cuDNN).
-# USE_CUDNN := 1
+USE_CUDNN := 1

 # CPU-only switch (uncomment to build without GPU support).
 # CPU_ONLY := 1
 # CPU_ONLY := 1

 # uncomment to disable IO dependencies and corresponding data layers
-# USE_OPENCV := 0
+USE_OPENCV := 0
 # USE_LEVELDB := 0
 # USE_LMDB := 0
 # This code is taken from https://github.com/sh1r0/caffe-android-lib
@@ -20,7 +20,7 @@
 # ALLOW_LMDB_NOLOCK := 1

 # Uncomment if you're using OpenCV 3
-# OPENCV_VERSION := 3
+OPENCV_VERSION := 3

 # To customize your choice of compiler, uncomment and set the following.
 # N.B. the default for Linux is g++ and the default for OSX is clang++
@@ -36,15 +36,10 @@ CUDA_DIR := /usr/local/cuda
 # For CUDA < 6.0, comment the *_50 through *_61 lines for compatibility.
 # For CUDA < 8.0, comment the *_60 and *_61 lines for compatibility.
 # For CUDA >= 9.0, comment the *_20 and *_21 lines for compatibility.
-CUDA_ARCH := -gencode arch=compute_20,code=sm_20 \
-               -gencode arch=compute_20,code=sm_21 \
-               -gencode arch=compute_30,code=sm_30 \
-               -gencode arch=compute_35,code=sm_35 \
-               -gencode arch=compute_50,code=sm_50 \
-               -gencode arch=compute_52,code=sm_52 \
-               -gencode arch=compute_60,code=sm_60 \
-               -gencode arch=compute_61,code=sm_61 \
-               -gencode arch=compute_61,code=compute_61
+CUDA_ARCH := -gencode arch=compute_53,code=sm_53 \
+               -gencode arch=compute_62,code=sm_62 \
+               -gencode arch=compute_72,code=sm_72 \
+               -gencode arch=compute_72,code=compute_72

 # BLAS choice:
 # atlas for ATLAS (default)
@@ -94,7 +89,7 @@ PYTHON_LIB := /usr/lib
 # WITH_PYTHON_LAYER := 1

 # Whatever else you find you need goes here.
-INCLUDE_DIRS := $(PYTHON_INCLUDE) /usr/local/include
+INCLUDE_DIRS := $(PYTHON_INCLUDE) /usr/local/include /usr/include/hdf5/serial/
 LIBRARY_DIRS := $(PYTHON_LIB) /usr/local/lib /usr/lib

 # If Homebrew is installed at a non standard location (for example your home directory) and you use it for general dependencies
$ cp Makefile.config.example Makefile.config
$ make -j4 all
...

Thanks.

I Will check that out today. Still doubtful if is is compiled as I have Open Cv Version 4.1.1 and make file line is OPENCV_VERSION := 3.

Didn’t work out yet Shall I set OPENCV_VERSION := 4 ?

Hi,

You can find some information from the make configure.
The OPENCV_VERSION := 3 is used to distinguish the implementation of opencv_imgcodecs.
This can be applied on the version greater than 2.x.

There is no update from you for a period, assuming this is not an issue any more.
Hence we are closing this topic. If need further support, please open a new one.
Thanks

Could you share the detailed error you meet with us?

Thanks.