Processing 2D Array in Pycuda

#labels is a 2d array

areas = np.zeros(n-1);
rows = len(labels)
cols = len(labels[0])

for i in range(0, rows):
for j in range(0, cols):
if(labels[i][j] != 0):
areas[(labels[i][j]-1)] += 1

This is part of my code written in django and python. Can someone help me translating this code into a kernel in Pycuda? I’m kinda new in CUDA Programming. The elements of labels are simply integers and i need to check the frequency of each integer found in the 2d array.