/ ai

Fixing Caffe installation issues on Ubuntu 16.04

You may run into the following problem while installing Caffe:

CXX src/caffe/util/cudnn.cpp
In file included from /usr/local/cuda-8.0/include/channel_descriptor.h:62:0,
                 from /usr/local/cuda-8.0/include/cuda_runtime.h:90,
                 from /usr/include/cudnn.h:64,
                 from ./include/caffe/util/cudnn.hpp:5,
                 from src/caffe/util/cudnn.cpp:2:
/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);
                                                                                                     ^
In file included from /usr/local/cuda-8.0/include/channel_descriptor.h:62:0,
                 from /usr/local/cuda-8.0/include/cuda_runtime.h:90,
                 from /usr/include/cudnn.h:64,
                 from ./include/caffe/util/cudnn.hpp:5,
                 from src/caffe/util/cudnn.cpp:2:
/usr/local/cuda-8.0/include/cuda_runtime_api.h:5382:92: error: use of enum ‘cudaMemoryAdvise’ without previous declaration
 extern __host__ cudaError_t CUDARTAPI cudaMemAdvise(const void *devPtr, size_t count, enum cudaMemoryAdvise advice, int device);
                                                                                            ^
/usr/local/cuda-8.0/include/cuda_runtime_api.h:5438:98: error: use of enum ‘cudaMemRangeAttribute’ without previous declaration
 extern __host__ cudaError_t CUDARTAPI cudaMemRangeGetAttribute(void *data, size_t dataSize, enum cudaMemRangeAttribute attribute, const void *devPtr, size_t count);
                                                                                                  ^
/usr/local/cuda-8.0/include/cuda_runtime_api.h:5474:102: error: use of enum ‘cudaMemRangeAttribute’ without previous declaration
 extern __host__ cudaError_t CUDARTAPI cudaMemRangeGetAttributes(void **data, size_t *dataSizes, enum cudaMemRangeAttribute *attributes, size_t numAttributes, const void *devPtr, size_t count);
                                                                                                      ^
Makefile:581: recipe for target '.build_release/src/caffe/util/cudnn.o' failed
make: *** [.build_release/src/caffe/util/cudnn.o] Error 1

The problems are almost always caused by a corrupted CUDA install. If reinstalling CUDA didn't help, edit the following file:

/usr/include/cudnn.h

... and change

include "driver_types.h"

... to

include <driver_types.h>

Recompile.