Skip to content

Instantly share code, notes, and snippets.

@rpratesh
Last active March 1, 2018 13:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rpratesh/dae84f3bdc61dc757dd66fabd8503819 to your computer and use it in GitHub Desktop.
Save rpratesh/dae84f3bdc61dc757dd66fabd8503819 to your computer and use it in GitHub Desktop.
Install NV_Caffe in NVIDIA Jetson TX1

Install the pre-prequisites: sudo apt-get update
sudo apt-get install software-properties-common
sudo add-apt-repository universe
sudo add-apt-repository multiverse

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

For now only NV_caffe-0.15 is working with TX1 with JetPack 3.1 (which had TensorRT2.1)

Pull nv_caffe-0.15 from nvidia's github repo:
git clone -b caffe-0.15 https://github.com/NVIDIA/caffe.git

Make following changes in some file before building (have used diff format):

In <caffe_home>/3rdparty/cub/host/mutex.cuh file :

@@ -121,7 +121,7 @@ struct Mutex
        */
       __forceinline__ void YieldProcessor()
       {
-        #ifndef __arm__
+        #if !defined(__arm__) && !defined(__aarch64__)
               asm volatile("pause\n": : :"memory");
       #endif  // __arm__
       }

In <caffe_home>/Makefile:

 ```
 @@ -180,7 +180,7 @@ ifneq ($(CPU_ONLY), 1)
      LIBRARIES := cudart cublas curand
endif

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

# handle IO dependencies
USE_LEVELDB ?= 1

```

In <caffe_home>/Makefile.config.example:

 # cuDNN acceleration switch (uncomment to build with cuDNN).
# cuDNN version 4 or higher is required.
-# USE_CUDNN := 1
+USE_CUDNN := 1

# NCCL acceleration switch (uncomment to build with NCCL)
# See https://github.com/NVIDIA/nccl

@@ -43,6 +43,7 @@ CUDA_ARCH := -gencode arch=compute_20,code=sm_20 \
              -gencode arch=compute_30,code=sm_30 \
              -gencode arch=compute_35,code=sm_35 \
              -gencode arch=compute_50,code=sm_50 \
+               -gencode arch=compute_53,code=sm_53 \
              -gencode arch=compute_50,code=compute_50

# BLAS choice:
@@ -90,7 +91,7 @@ PYTHON_LIB := /usr/lib
-# WITH_PYTHON_LAYER := 1
+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

Next steps:

cp Makefile.config.example Makefile.config
make -j4
make pycaffe
export PYTHONPATH=<caffe-home>/python:$PYTHONPATH

Check installation:
$ Python >> import caffe

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment