# Install guide for Autoware's object detection(SSD) in Ubuntu 16.04
* Requirement
* Autoware (Below v1.1.9)
* nvidia graphic card driver (>367)
* gcc/g++ 5.4.0 (Important!)
* ROS and autoware
* 3GB nvidia GPU(Above 4GB is better)
* If GPU's memory is too small, it can't load ssd's model.
## Cuda 8.0
* [Please remove cuda if it existed](https://askubuntu.com/questions/530043/removing-nvidia-cuda-toolkit-and-installing-new-one)
* [Download cuda8.0](https://developer.nvidia.com/cuda-80-ga2-download-archive)
```shell=
sudo sh cuda_8.x.xxx.xx_linux.run
## (Do not install nvidia driver)
## Add data depedenice
export CUDA_HOME=/usr/local/cuda
export PATH=$PATH:$CUDA_HOME/bin
export LD_LIBRARY_PATH=/usr/local/cuda/lib64${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}
source ~/.bashrc
## testing
nvcc -V
```
## cudnn 7.1.3
* [Download cuDNN v7.1.3 (April 17, 2018), for CUDA 8.0](https://developer.nvidia.com/rdp/cudnn-archive)
* You will get the "cuda" folder:
> cuda
>> include
>> lib64
```shell=
tar xvf cudnn-8.0-linux-x64-v7.1.tgz
sudo cp ./your_path/cuda/include/cudnn.h /usr/local/cuda/include/
sudo cp ./your_path/cuda/lib64/lib* /usr/local/cuda/lib64/
cd /usr/local/cuda/lib64/
sudo rm -rf libcudnn.so libcudnn.so.7
##Notice your version (7.1.3 or others)
sudo ln -s libcudnn.so.7.1.3 libcudnn.so.5
sudo ln -s libcudnn.so.7 libcudnn.so
## You may download the cudnn samples from the official link to test the avalibility
```
## Caffe
### Install SSD and it's dependencies
```
cd ~
git clone -b ssd https://github.com/weiliu89/caffe.git ssdcaffe
cd ssdcaffe
git checkout 4817bf8b4200b35ada8ed0dc378dceaf38c539e4
# SSD dependencies
sudo apt-get update
sudo apt-get install libopenblas-dev
sudo apt-get install -y --allow-unauthenticated libprotobuf-dev libleveldb-dev libsnappy-dev libopencv-dev libhdf5-serial-dev protobuf-compiler
sudo apt-get install --no-install-recommends -y --allow-unauthenticated libboost-all-dev
sudo apt-get install -y --allow-unauthenticated libatlas-base-dev libgoogle-glog-dev libgflags-dev liblmdb-dev
sudo apt-get install -y --allow-unauthenticated libhdf5-10 libhdf5-serial-dev libhdf5-dev libhdf5-cpp-11
```
### Setting the Makefile.config
* example:
```shell=
CUDA_DIR := /usr/local/cuda
CUDA_ARCH := -gencode arch=compute_35,code=sm_35 -gencode arch=compute_53,code=sm_53 -gencode arch=compute_53,code=compute_53
USE_CUDNN := 1
BLAS := atlas
PYTHON_INCLUDE := /usr/include/python2.7 /usr/lib/python2.7/dist-packages/numpy/core/include
PYTHON_LIB := /usr/lib
INCLUDE_DIRS := $(PYTHON_INCLUDE) /usr/local/include /usr/include/hdf5/serial
LIBRARY_DIRS := $(PYTHON_LIB) /usr/local/lib /usr/lib /usr/lib/x86_64-linux-gnu/hdf5/serial
BUILD_DIR := build
DISTRIBUTE_DIR := distribute
TEST_GPUID := 0
Q ?= @
```
* You should console your compute capability of GPU
* For example, GTX1060 is 6.1. You should add `-gencode arch=compute_61,code=sm_61` in CUDA_ARCH
* [compute capability](https://blog.csdn.net/JiaJunLee/article/details/52067962)
* [Reference(Chinese)](https://blog.csdn.net/qq_38451119/article/details/84549744)
* If you are using TX2, please notice that your hdf5 directory is *aarch64-linux-gnu*, not *x86_64-linux-gnu*.
* Make
```shell=
cd ~/ssdcaffe
make & make distribute
```
* Then, you can compile Autoware by catkin_make.
## Problems
* ./catkin_make_release error
* Please use:`./catkin_make_release -j1` to check errors.
1. [error: argument of type "const void *" is incompatible with...](https://github.com/tensorflow/tensorflow/issues/10220)
* sol: Pass args to catkin_make in the bash file.
`CXX=g++5 CC=gcc5 catkin_make`
### Other problem you may occur (Chinese)
https://blog.csdn.net/u012576214/article/details/68947893
https://blog.csdn.net/kemgine/article/details/78781377
https://blog.csdn.net/xunan003/article/details/79137585
## For Tegra TX2
* You need a computer with x86 architecture and Ubuntu 16.04 or 18.04. It's to use Jetpack in both solution.
### Solution 1 : Flash
* Please download [Jetpack 3.3 ](https://developer.nvidia.com/embedded/jetpack-3_3) (or above) and follow the install guide.
### Solution 2 : Not Flash
* If you don't want to flash the TX2, you can download the .deb files and install manually.
* Please download [Jetpack 3.1](https://developer.nvidia.com/embedded/dlc/jetpack-l4t-3_1). This version is compatible for the TX2's origin version of driver.
* Download the .deb file of Cuda and Cudnn.
* Follow the [link](https://gist.github.com/ShreyasSkandan/69f727d48f85d34e0e9b26308ade0040#file-setup_cuda_tx2-sh-L30) to install Cuda.
* Install Cudnn's .deb package directly.
### Compile Autoware
* Because Driveworks is not supported on TX2, you need to add it to blacklist when compiling.
```xml=
./catkin_make_release -DCATKIN_BLACKLIST_PACKAGES="autoware_driveworks_interface;autoware_driveworks_gmsl_interface
```
(If you want to trace error message, add -j1.)
* [reference](https://github.com/autowarefoundation/autoware/issues/1973)