Loading...
cudaErrorTooManyBlocks (802)cudaErrorTooManyBlocks occurs when launching a kernel with more blocks than the GPU supports.
CUDA error: too many blocks cudaErrorTooManyBlocks
Query max grid size.
cudaDeviceProp prop;
cudaGetDeviceProperties(&prop, 0);
printf("Max grid: %d x %d x %d\n",
prop.maxGridSize[0], prop.maxGridSize[1], prop.maxGridSize[2]);Use multiple launches.
for (int offset = 0; offset < totalBlocks; offset += maxBlocks) {
int blocks = min(maxBlocks, totalBlocks - offset);
kernel<<<blocks, threads>>>(data, offset);
}Exceeds device limit.
kernel<<<1000000000, 256>>>(); // Way too manyRespect device limit.
int maxGrid = prop.maxGridSize[0];
int blocks = min(required, maxGrid);Typically 2^31-1 in x dimension, 65535 in y and z.
Need help debugging CUDA errors? Download RightNow AI for intelligent error analysis and optimization suggestions.