Fixing py-faster-rcnn for cuDNN5

First of all, a big thanks to Ross Girshick for sharing this amazing implementation for the benefit of the mere-mortals like me 🙂 It is one of the most clearly written, well structured and nicely commented code that I have come across.

However, at times, you do get stuck into in getting the demo up and running due to minor compatibility issues. This gets immensely frustrating at time because you came here to do awesome object detection and not bug detection. Although, bug is also an object 😛

In this article, I wanted to document the issues faced by me and their resolution. The main issue was that I was using cuDNN version 5 which seems to be the case with lot of people.

Cut the Trap and Just give me the code. 😀

Folks who want to skip the details can directly clone this fork.

I have made some changes in the main code as well as the caffe code. I have only tested this code for demo for now. Let me know if you face issues while retraining.

System Specifications

Ubuntu Version: 14.04

CUDA Version: 8.0, V8.0.61

CUDNN Version: 5

Error

After cloning the repo, when I try to install caffe by running following command,

make -j8 && make pycaffe

I run into lot of issues like:

/include/caffe/util/cudnn.hpp: In function ‘void caffe::cudnn::createPoolingDesc(cudnnPoolingStruct**, caffe::PoolingParameter_PoolMethod, cudnnPoolingMode_t*, int, int, int, int, int, int)’:
./include/caffe/util/cudnn.hpp:127:41: error: too few arguments to function ‘cudnnStatus_t cudnnSetPooling2dDescriptor(cudnnPoolingDescriptor_t, cudnnPoolingMode_t, cudnnNanPropagation_t, int, int, int, int, int, int)’
pad_h, pad_w, stride_h, stride_w));
^

Diagnosis

After some searching, I found the issue is due to the incompatibility with cuDNN version 5.

The best way to get hold of the issue was to downgrade to version 4 but I wanted to have some fun 🙂

So, I kept fixing one issue after the other and got the demo running atleast.

Resolution

The first step is to pull and merge the latest caffe code from the caffe repository in the caffe-fast-rcnn module. There are few minor conflicts. I have taken all the latest code changes and purged the older ones.

I also needed to make small changes here and there. Feel free to review the commit history and suggest improvements.

The caffe submodule compiles nicely after these changes.

Code

The updated code is located here. Do not forget to switch to the “faster-rcnn” branch.

The next step was to try if the demo runs with this updated caffe version.

I ran the following command,

./tools/demo.py

and got “Attribute Error”.

Actually, I needed to make one more small change in the “python_layer.hpp” and then I was good to go!

The demo ran perfectly 🙂

You can find this updated code here.

I am yet to test if retraining also works fine but I think we will do it one step at a time 🙂

Source: Deep Learning on Medium