BVLC/caffe — pull request #707 by OpenHero (2014-07-16 06:47:49+00:00)
Title: Fix a bug

When the Compute Capability of CUDA is < 3.0, the Maximum x-dimension of a grid of thread blocks is 65535. So the Kernel will crash when the CAFFE_GET_BLOCKS is bigger than 65535. Like Fermi architecture GPUs.

The crash will happen in src/caffe/layers/relu_layer.cu line 29. as #282 #12

Fixed it with
// CUDA: number of blocks for threads.
inline int CAFFE_GET_BLOCKS(const int N) {
//return (N + CAFFE_CUDA_NUM_THREADS - 1) / CAFFE_CUDA_NUM_THREADS;
int num_blocks = (N + CAFFE_CUDA_NUM_THREADS - 1) / CAFFE_CUDA_NUM_THREADS;
return num_blocks > Caffe::cuProp().maxGridSize[0]? num_blocks : Caffe::cuProp().maxGridSize[0];
}