cuDNN v6.0でssdcaffeをビルドする時に詰まった事メモ

##環境
CPU: x86_64
OS: ubuntu 16.04.4 LTS
CUDA: V8.0.61
cuDNN: v6.0.21

##cmake ..のエラー
```
...(略)
Could NOT find LMDB(missing: LMDB_INCLUDE_DIR LMDB_LIBRARIES)
...(略)
```
http://caffe.berkeleyvision.org/install_apt.html
の14.04向けの依存パッケージも要るらしい。なので、

```
sudo apt-get install libgflags-dev libgoogle-glog-dev liblmdb-dev
```

## ERROR in make && make distribute
```
hdf5.h: No such file or directory
```
follow this : 
https://github.com/NVIDIA/DIGITS/issues/156
https://github.com/BVLC/caffe/issues/2347 -> CDLuminate's first suggestion.

## ERROR in make && make distribute
```
/usr/bin/ld: cannot find -lhdf5_hl
/usr/bin/ld: cannot find -lhdf5
```
https://github.com/NVIDIA/DIGITS/issues/156 -> tangshi's suggestion helped me


##cuDNNのバージョンエラー

```
[  1%] Building NVCC (Device) object src/caffe/CMakeFiles/cuda_compile.dir/util/cuda_compile_generated_bbox_util.cu.o
../ssdcaffe/include/caffe/util/cudnn.hpp(112): error: too few arguments in function call
```
https://github.com/weiliu89/caffe/issues/534 を参考に、
https://github.com/BVLC/caffe/commit/0096fe3d270a4833479076e18492de8b28564c80
のコミット内容をコピペして解決

##cuda_runtime_api.h内で関数未定義のエラー

```
[ 36%] Building CXX object src/caffe/CMakeFiles/caffe.dir/util/cudnn.cpp.o
(略)
/usr/local/cuda-8.0/include/cuda_runtime_api.h:1628:101: error: use of enum ‘cudaDeviceP2PAttr’ without previous declaration
 extern __host__ __cudart_builtin__ cudaError_t CUDARTAPI cudaDeviceGetP2PAttribute(int *value, enum cudaDeviceP2PAttr attr, int srcDevice, int dstDevice);
                                                                                                     ^
```
https://github.com/Theano/Theano/issues/5856 を参考に、

```/usr/include/cudnn.h
-#include "driver_types.h"
+#include <driver_types.h>
```
で解決

#TIFFライブラリ周りでエラー
```
[ 83%] Linking CXX executable compute_image_mean
/opt/ros/kinetic/lib/libopencv_imgcodecs3.so.3.3.1: undefined reference to `TIFFReadDirectory@LIBTIFF_4.0'
/opt/ros/kinetic/lib/libopencv_imgcodecs3.so.3.3.1: undefined reference to `TIFFWriteEncodedStrip@LIBTIFF_4.0'
/opt/ros/kinetic/lib/libopencv_imgcodecs3.so.3.3.1: undefined reference to `TIFFIsTiled@LIBTIFF_4.0'
/opt/ros/kinetic/lib/libopencv_imgcodecs3.so.3.3.1: undefined reference to `TIFFScanlineSize@LIBTIFF_4.0'
/opt/ros/kinetic/lib/libopencv_imgcodecs3.so.3.3.1: undefined reference to `TIFFRGBAImageOK@LIBTIFF_4.0'
/opt/ros/kinetic/lib/libopencv_imgcodecs3.so.3.3.1: undefined reference to `TIFFClose@LIBTIFF_4.0'
/opt/ros/kinetic/lib/libopencv_imgcodecs3.so.3.3.1: undefined reference to `TIFFSetWarningHandler@LIBTIFF_4.0'
/opt/ros/kinetic/lib/libopencv_imgcodecs3.so.3.3.1: undefined reference to `TIFFWriteScanline@LIBTIFF_4.0'
/opt/ros/kinetic/lib/libopencv_imgcodecs3.so.3.3.1: undefined reference to `TIFFGetField@LIBTIFF_4.0'
/opt/ros/kinetic/lib/libopencv_imgcodecs3.so.3.3.1: undefined reference to `TIFFNumberOfStrips@LIBTIFF_4.0'
/opt/ros/kinetic/lib/libopencv_imgcodecs3.so.3.3.1: undefined reference to `TIFFReadEncodedTile@LIBTIFF_4.0'
/opt/ros/kinetic/lib/libopencv_imgcodecs3.so.3.3.1: undefined reference to `TIFFReadRGBATile@LIBTIFF_4.0'
/opt/ros/kinetic/lib/libopencv_imgcodecs3.so.3.3.1: undefined reference to `TIFFClientOpen@LIBTIFF_4.0'
/opt/ros/kinetic/lib/libopencv_imgcodecs3.so.3.3.1: undefined reference to `TIFFOpen@LIBTIFF_4.0'
/opt/ros/kinetic/lib/libopencv_imgcodecs3.so.3.3.1: undefined reference to `TIFFReadEncodedStrip@LIBTIFF_4.0'
/opt/ros/kinetic/lib/libopencv_imgcodecs3.so.3.3.1: undefined reference to `TIFFSetField@LIBTIFF_4.0'
/opt/ros/kinetic/lib/libopencv_imgcodecs3.so.3.3.1: undefined reference to `TIFFSetErrorHandler@LIBTIFF_4.0'
/opt/ros/kinetic/lib/libopencv_imgcodecs3.so.3.3.1: undefined reference to `TIFFReadRGBAStrip@LIBTIFF_4.0'
collect2: error: ld returned 1 exit status
tools/CMakeFiles/compute_image_mean.dir/build.make:140: recipe for target 'tools/compute_image_mean' failed
make[2]: *** [tools/compute_image_mean] Error 1
CMakeFiles/Makefile2:479: recipe for target 'tools/CMakeFiles/compute_image_mean.dir/all' failed
make[1]: *** [tools/CMakeFiles/compute_image_mean.dir/all] Error 2
Makefile:127: recipe for target 'all' failed
make: *** [all] Error 2
```
https://github.com/BVLC/caffe/issues/1559 を参考に、

```
$ sudo conda uninstall libtiff
[sudo] password for hoge: 
Solving environment: done


==> WARNING: A newer version of conda exists. <==
  current version: 4.4.10
  latest version: 4.5.0

Please update conda by running

    $ conda update -n base conda



## Package Plan ##

  environment location: /home/hoge/anaconda2

  removed specs: 
    - libtiff


The following packages will be REMOVED:

    anaconda:           5.1.0-py27_2    
    anaconda-navigator: 1.7.0-py27_0    
    libtiff:            4.0.9-h28f6b97_0

Proceed ([y]/n)? y

Preparing transaction: done
Verifying transaction: done
Executing transaction: done
```

でビルドできた！