Failed to build Caffe on Tx2 R28.2

I encountered an error as building Caffe source on TX2 R28.2.

Here is the error message.
nvidia@tegra-ubuntu:~/Work/caffe/caffe-master$ make -j4
PROTOC src/caffe/proto/caffe.proto
make: protoc: Command not found
NVCC src/caffe/solvers/nesterov_solver.cu
Makefile:638: recipe for target ‘.build_release/src/caffe/proto/caffe.pb.cc’ failed
make: *** [.build_release/src/caffe/proto/caffe.pb.cc] Error 127
make: *** Waiting for unfinished jobs…
NVCC src/caffe/solvers/adagrad_solver.cu
nvcc fatal : Unsupported gpu architecture ‘compute_20’
Makefile:594: recipe for target ‘.build_release/cuda/src/caffe/solvers/nesterov_solver.o’ failed
make: *** [.build_release/cuda/src/caffe/solvers/nesterov_solver.o] Error 1
nvcc fatal : Unsupported gpu architecture ‘compute_20’
Makefile:594: recipe for target ‘.build_release/cuda/src/caffe/solvers/adagrad_solver.o’ failed
make: *** [.build_release/cuda/src/caffe/solvers/adagrad_solver.o] Error 1

Did I miss any?
Thank you for any advice.

Below are the commands I did for building Caffe on Tx2.
a) Install packages from APT with the following commands:

    $ sudo add-apt-repository universe
    $ sudo add-apt-repository multiverse
    $ sudo apt-get update
    $ sudo apt-get install libboost-all-dev libprotobuf-dev libleveldb-dev libsnappy-dev
    $ sudo apt-get install libhdf5-serial-dev protobuf-compiler libgflags-dev libgoogle-glog-dev
    $ sudo apt-get install liblmdb-dev libblas-dev libatlas-base-dev

b) Download Caffe source package from the following website:

    https://github.com/BVLC/caffe

   And copy the package to $HOME directory on the target board
   with the following command:

    $ mkdir -pv $HOME/Work/caffe
    $ cp caffe-master.zip $HOME/Work/caffe/
    $ cd $HOME/Work/caffe/ && unzip caffe-master.zip

c) Build Caffe source with the following commands:

    $ cd $HOME/Work/caffe/caffe-master
    $ vi Makefile.config.example

    Uncomment the following line to enable cuDNN acceleration:

        USE_CUDNN := 1

    And modify the following two lines, save, and exit.

        INCLUDE_DIRS := $(PYTHON_INCLUDE) /usr/local/include /usr/include/hdf5/serial
        LIBRARY_DIRS := $(PYTHON_LIB) /usr/local/lib /usr/lib /usr/lib/aarch64-linux-gnu/hdf5/serial

    $ cp Makefile.config.example Makefile.config
    $ make -j4

I have done NVCaffe setup on TX2, These are the steps:

Download nvcaffe-0.17

open https://github.com/NVIDIA/caffe
click on branch:master
click on caffe-0.17
click on clone and download option
click on Download ZIP, it will start downloading the caffe version 0.17
create folder nvcaffe in /home/nvidia/
extract caffe-0.17 in nvcaffe folder

Installing Dependencies

sudo apt-get install cmake libprotobuf-dev libleveldb-dev libsnappy-dev libhdf5-serial-dev protobuf-compiler libboost-dev libboost-all-dev libgflags-dev libgoogle-glog-dev liblmdb-dev libopenblas-dev libturbojpeg libjpeg-dev python-numpy -y
sudo ln -s /usr/lib/libsnappy.so.1 /usr/lib/libsnappy.so
sudo ldconfig
sudo ln -s /usr/lib/aarch64-linux-gnu/libhdf5_serial.so.10 /usr/lib/aarch64-linux-gnu/libhdf5.so
sudo ln -s /usr/lib/aarch64-linux-gnu/libhdf5_serial_hl.so.10 /usr/lib/aarch64-linux-gnu/libhdf5_hl.so
sudo ln -s /usr/lib/aarch64-linux-gnu/libturbojpeg.so.0.1.0 /usr/lib/aarch64-linux-gnu/libturbojpeg.so

edit /home/nvidia/nvcaffe/caffe-0.17.0/3rdparty/cub/host/mutex.cuh file

<i><b>change line 127</b></i>
	#ifndef __arm__
<i><b>to</b></i>
	#if !defined(__arm__) && !defined(__aarch64__)

edit /home/nvidia/nvcaffe/caffe-0.17.0/Makefile.config

<i><b>change line 6</b></i>
	#USE_CUDNN := 1
<i><b>to</b></i>
	USE_CUDNN := 1

<i><b>change line 37</b></i>
	-gencode arch=compute_61,code=sm_61 \
<i><b>to</b></i>
	-gencode arch=compute_53,code=sm_53 \
	-gencode arch=compute_62,code=sm_62 \

<i><b>change</b></i> 
	LIBRARY_DIRS := $(PYTHON_LIB) /usr/local/lib /usr/lib /usr/lib/x86_64-linux-gnu/hdf5/serial
<i><b>to</b></i>
	#LIBRARY_DIRS := $(PYTHON_LIB) /usr/local/lib /usr/lib /usr/lib/x86_64-linux-gnu/hdf5/serial
	LIBRARY_DIRS := $(PYTHON_LIB) /usr/local/lib /usr/lib /usr/lib/aarch64-linux-gnu/hdf5/serial

save the file

build using following command

make -j6
make pycaffe

Hi,

Please check this comment for the installation steps of Caffe on Jetson.
https://devtalk.nvidia.com/default/topic/1021931/jetson-tx2/nvcaffe-support-on-tx2/post/5200686/#5200686

Thanks and please also let us know the result.

Thanks darjibhavinr and AastaLLL for your prompt supports.
Followed darjibhavinr’s commands and still got error. (see message below.)
Due to Jetpack3.2 does not install opencv4tegra by default, I actually installed opencv manually.
And can import cv2 successfully on python 2.7.
Plus, jetpack3.2 supports tr3.0, therefore I used nvcaffe 0.17.

;;-----------------------------------------------
make: *** [.build_release/tools/compute_image_mean.bin] Error 1
nvidia@tegra-ubuntu:~/nvcaffe/caffe-caffe-0.17$ make -j6
CXX/LD -o .build_release/tools/get_image_size.bin
CXX/LD -o .build_release/tools/upgrade_solver_proto_text.bin
CXX/LD -o .build_release/tools/convert_annoset.bin
CXX/LD -o .build_release/tools/extract_features.bin
CXX/LD -o .build_release/tools/upgrade_net_proto_binary.bin
CXX/LD -o .build_release/tools/compute_image_mean.bin
/usr/bin/ld: warning: libopencv_core.so.3.4, needed by .build_release/lib/libcaffe-nv.so, may conflict with libopencv_core.so.3.3
/usr/bin/ld: warning: libopencv_highgui.so.3.4, needed by .build_release/lib/libcaffe-nv.so, may conflict with libopencv_highgui.so.3.3
.build_release/lib/libcaffe-nv.so: undefined reference to cv::VideoCapture::set(int, double)' .build_release/lib/libcaffe-nv.so: undefined reference to cv::VideoWriter::write(cv::Mat const&)’
.build_release/lib/libcaffe-nv.so: undefined reference to cv::VideoCapture::open(cv::String const&)' .build_release/lib/libcaffe-nv.so: undefined reference to cv::VideoCapture::release()’
.build_release/lib/libcaffe-nv.so: undefined reference to cv::VideoCapture::operator>>(cv::Mat&)' .build_release/lib/libcaffe-nv.so: undefined reference to cv::VideoWriter::VideoWriter(cv::String const&, int, double, cv::Size_, bool)’
.build_release/lib/libcaffe-nv.so: undefined reference to cv::VideoCapture::isOpened() const' .build_release/lib/libcaffe-nv.so: undefined reference to cv::VideoCapture::get(int) const’
.build_release/lib/libcaffe-nv.so: undefined reference to cv::VideoWriter::VideoWriter()' .build_release/lib/libcaffe-nv.so: undefined reference to cv::VideoCapture::open(int)’
.build_release/lib/libcaffe-nv.so: undefined reference to cv::VideoWriter::isOpened() const' .build_release/lib/libcaffe-nv.so: undefined reference to cv::VideoWriter::~VideoWriter()’
.build_release/lib/libcaffe-nv.so: undefined reference to cv::VideoCapture::~VideoCapture()' .build_release/lib/libcaffe-nv.so: undefined reference to cv::VideoCapture::VideoCapture()’
collect2: error: ld returned 1 exit status
/usr/bin/ld: warning: libopencv_core.so.3.4, needed by .build_release/lib/libcaffe-nv.so, may conflict with libopencv_core.so.3.3
/usr/bin/ld: warning: libopencv_highgui.so.3.4, needed by .build_release/lib/libcaffe-nv.so, may conflict with libopencv_highgui.so.3.3
.build_release/lib/libcaffe-nv.so: undefined reference to cv::VideoCapture::set(int, double)' .build_release/lib/libcaffe-nv.so: undefined reference to cv::VideoWriter::write(cv::Mat const&)’
.build_release/lib/libcaffe-nv.so: undefined reference to cv::VideoCapture::open(cv::String const&)' .build_release/lib/libcaffe-nv.so: undefined reference to cv::VideoCapture::release()’
.build_release/lib/libcaffe-nv.so: undefined reference to `cv::VideoCapture::operator>Makefile:654: recipe for target ‘.build_release/tools/upgrade_solver_proto_text.bin’ failed

(cv::Mat&)’
.make: *** [.build_release/tools/upgrade_solver_proto_text.bin] Error 1
build_release/lib/libcaffe-nv.so: undefined reference to cv::VideoWriter::VideoWriter(cv::String const&, int, double, cv::Size_<int>, bool)' .build_release/lib/libcaffe-nv.so: undefined reference to cv::VideoCapture::isOpened() const’
.build_release/lib/libcaffe-nv.so: undefined reference to cv::VideoCapture::get(int) const' .build_release/lib/libcaffe-nv.so: undefined reference to cv::VideoWriter::VideoWriter()’
.build_release/lib/libcaffe-nv.so: undefined reference to cv::VideoCapture::open(int)' .build_release/lib/libcaffe-nv.so: undefined reference to cv::VideoWriter::isOpened() make: *** Waiting for unfinished jobs…
const’
.build_release/lib/libcaffe-nv.so: undefined reference to cv::VideoWriter::~VideoWriter()' .build_release/lib/libcaffe-nv.so: undefined reference to cv::VideoCapture::~VideoCapture()’
.build_release/lib/libcaffe-nv.so: undefined reference to cv::VideoCapture::VideoCapture()' collect2: error: ld returned 1 exit status Makefile:654: recipe for target '.build_release/tools/upgrade_net_proto_binary.bin' failed make: *** [.build_release/tools/upgrade_net_proto_binary.bin] Error 1 /usr/bin/ld: warning: libopencv_core.so.3.4, needed by .build_release/lib/libcaffe-nv.so, may conflict with libopencv_core.so.3.3 /usr/bin/ld: warning: libopencv_highgui.so.3.4, needed by .build_release/lib/libcaffe-nv.so, may conflict with libopencv_highgui.so.3.3 .build_release/lib/libcaffe-nv.so: undefined reference to cv::VideoCapture::set(int, double)’
.build_release/lib/libcaffe-nv.so: undefined reference to cv::VideoWriter::write(cv::Mat const&)' .build_release/lib/libcaffe-nv.so: undefined reference to cv::VideoCapture::open(cv::String const&)’
.build_release/lib/libcaffe-nv.so: undefined reference to cv::VideoCapture::release()' .build_release/lib/libcaffe-nv.so: undefined reference to cv::VideoCapture::operator>>(cv::Mat&)’
.build_release/lib/libcaffe-nv.so: undefined reference to cv::VideoWriter::VideoWriter(cv::String const&, int, double, cv::Size_<int>, bool)' .build_release/lib/libcaffe-nv.so: undefined reference to cv::VideoCapture::isOpened() const’
.build_release/lib/libcaffe-nv.so: undefined reference to cv::VideoCapture::get(int) const' .build_release/lib/libcaffe-nv.so: undefined reference to cv::VideoWriter::VideoWriter()’
.build_release/lib/libcaffe-nv.so: undefined reference to cv::VideoCapture::open(int)' .build_release/lib/libcaffe-nv.so: undefined reference to cv::VideoWriter::isOpened() const’
.build_release/lib/libcaffe-nv.so: undefined reference to cv::VideoWriter::~VideoWriter()' .build_release/lib/libcaffe-nv.so: undefined reference to cv::VideoCapture::~VideoCapture()’
.build_release/lib/libcaffe-nv.so: undefined reference to cv::VideoCapture::VideoCapture()' collect2: error: ld returned 1 exit status Makefile:654: recipe for target '.build_release/tools/convert_annoset.bin' failed make: *** [.build_release/tools/convert_annoset.bin] Error 1 /usr/bin/ld: warning: libopencv_core.so.3.4, needed by .build_release/lib/libcaffe-nv.so, may conflict with libopencv_core.so.3.3 /usr/bin/ld: warning: libopencv_highgui.so.3.4, needed by .build_release/lib/libcaffe-nv.so, may conflict with libopencv_highgui.so.3.3 .build_release/lib/libcaffe-nv.so: undefined reference to cv::VideoCapture::set(int, double)’
.build_release/lib/libcaffe-nv.so: undefined reference to cv::VideoWriter::write(cv::Mat const&)' .build_release/lib/libcaffe-nv.so: undefined reference to cv::VideoCapture::open(cv::String const&)’
.build_release/lib/libcaffe-nv.so: undefined reference to cv::VideoCapture::release()' .build_release/lib/libcaffe-nv.so: undefined reference to cv::VideoCapture::operator>>(cv::Mat&)’
.build_release/lib/libcaffe-nv.so: undefined reference to cv::VideoWriter::VideoWriter(cv::String const&, int, double, cv::Size_<int>, bool)' .build_release/lib/libcaffe-nv.so: undefined reference to cv::VideoCapture::isOpened() const’
.build_release/lib/libcaffe-nv.so: undefined reference to cv::VideoCapture::get(int) const' .build_release/lib/libcaffe-nv.so: undefined reference to cv::VideoWriter::VideoWriter()’
.build_release/lib/libcaffe-nv.so: undefined reference to cv::VideoCapture::open(int)' .build_release/lib/libcaffe-nv.so: undefined reference to cv::VideoWriter::isOpened() const’
.build_release/lib/libcaffe-nv.so: undefined reference to cv::VideoWriter::~VideoWriter()' .build_release/lib/libcaffe-nv.so: undefined reference to cv::VideoCapture::~VideoCapture()’
.build_release/lib/libcaffe-nv.so: undefined reference to cv::VideoCapture::VideoCapture()' collect2: error: ld returned 1 exit status Makefile:654: recipe for target '.build_release/tools/compute_image_mean.bin' failed make: *** [.build_release/tools/compute_image_mean.bin] Error 1 /usr/bin/ld: warning: libopencv_core.so.3.4, needed by .build_release/lib/libcaffe-nv.so, may conflict with libopencv_core.so.3.3 /usr/bin/ld: warning: libopencv_highgui.so.3.4, needed by .build_release/lib/libcaffe-nv.so, may conflict with libopencv_highgui.so.3.3 .build_release/lib/libcaffe-nv.so: undefined reference to cv::VideoCapture::set(int, double)’
.build_release/lib/libcaffe-nv.so: undefined reference to cv::VideoWriter::write(cv::Mat const&)' .build_release/lib/libcaffe-nv.so: undefined reference to cv::VideoCapture::open(cv::String const&)’
.build_release/lib/libcaffe-nv.so: undefined reference to cv::VideoCapture::release()' .build_release/lib/libcaffe-nv.so: undefined reference to cv::VideoCapture::operator>>(cv::Mat&)’
.build_release/lib/libcaffe-nv.so: undefined reference to cv::VideoWriter::VideoWriter(cv::String const&, int, double, cv::Size_<int>, bool)' .build_release/lib/libcaffe-nv.so: undefined reference to cv::VideoCapture::isOpened() const’
.build_release/lib/libcaffe-nv.so: undefined reference to cv::VideoCapture::get(int) const' .build_release/lib/libcaffe-nv.so: undefined reference to cv::VideoWriter::VideoWriter()’
.build_release/lib/libcaffe-nv.so: undefined reference to cv::VideoCapture::open(int)' .build_release/lib/libcaffe-nv.so: undefined reference to cv::VideoWriter::isOpened() const’
.build_release/lib//libcaffe-usrnv.so/: binundefined/ ldreference: to cv: :warningVideoWriter:: :~libopencv_core.so.3.4VideoWriter,( )needed' by .build_release./build_releaselib//liblibcaffe/-libcaffenv.so-:nv.so ,undefined mayreference conflictto with cv:libopencv_core.so.3.3:
VideoCapture/:usr:/~binVideoCapture/(ld):’
warning.:build_release /lib/libcaffelibopencv_highgui.so.3.4-,nv.so :needed undefinedby reference. build_releaseto/ lib/cvlibcaffe:-:nv.soVideoCapture,: :mayVideoCapture (conflict) ' with libopencv_highgui.so.3.3 .build_release/lib/libcaffe-nv.so: undefined reference to cv::VideoCapture::set(int, double)’
.build_release/lib/libcaffe-nv.so: undefined reference to cv::VideoWriter::write(collect2: error: ld returned 1 exit status cv::Mat const&)' .build_release/lib/libcaffe-nv.so: undefined reference to cv::VideoCapture::open(cv::String const&)’
.build_release/lib/libcaffe-nv.so: undefined reference to cv::VideoCapture::release()' .build_release/lib/libcaffe-nv.so: undefined reference to cv::VideoCapture::operator>>(cv::Mat&)’
.build_release/lib/libcaffe-nv.so: undefined reference to cv::VideoWriter::VideoWriter(cv::String const&, int, double, cv::Size_<int>, bool)' .build_release/lib/libcaffe-nv.so: undefined reference to cv::VideoCapture::isOpened() const’
.build_release/lib/libcaffe-nv.so: undefined reference to cv::VideoCapture::get(int) const' .build_release/lib/libcaffe-nv.so: undefined reference to cv::VideoWriter::VideoWriter()’
.build_release/lib/libcaffe-nv.so: undefined reference to cv::VideoCapture::open(int)' .build_release/lib/libcaffe-nv.so: undefined reference to cv::VideoWriter::isOpened() const’
.build_release/lib/libcaffe-nv.so: undefined reference to cv::VideoWriter::~VideoWriter()' .build_release/lib/libcaffe-nv.so: undefined reference to cv::VideoCapture::~VideoCapture()’
.build_release/lib/libcaffe-nv.so: undefined reference to `cv::VideoCapture::VideoCapture()’
collect2: error: ld returned 1 exit status
Makefile:654: recipe for target ‘.build_release/tools/get_image_size.bin’ failed
make: *** [.build_release/tools/get_image_size.bin] Error 1
Makefile:654: recipe for target ‘.build_release/tools/extract_features.bin’ failed
make: *** [.build_release/tools/extract_features.bin] Error 1
nvidia@tegra-ubuntu:~/nvcaffe/caffe-caffe-0.17$

Thank you for any advice.

Hello,
Jetpack3.2 does install opencv4tegra by default and its version is 3.3.1.

/usr/bin/ld: warning: libopencv_core.so.3.4, needed by .build_release/lib/libcaffe-nv.so, may conflict with libopencv_core.so.3.3

May be there is a conflict due to multiple version of OpenCV.

Before you install any other version of OpenCV you have to uninstall the previous version.

Remove opencv installed by jetpack 3.2

sudo apt-get purge libopencv*
sudo apt autoremove
sudo apt-get update
sudo apt-get dist-upgrade

After removing the setup you can install your own version.