 <p>I have changed the global code and some modification in datatype. This code works:</p> <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false"> <div class="snippet-code"> <pre class="snippet-code-html lang-html prettyprint-override"><code>from __future__ import print_function from __future__ import absolute_import from pycuda.compiler import SourceModule import pycuda.driver as drv import pycuda.autoinit # noqa import numpy as np import time import pandas as pd start_time = time.clock() mod = SourceModule(""" __global__ void similarityGPU(int inputmat[5][70], float similaritymat[5][5]) { int i = threadIdx.x; int j = 0, k=0; for(j=0 ; j&lt;5 ; j++){ float max = 0.0 , min = 0.0; for (k=0 ; k&lt;70 ; k++){ if(inputmat[i][k] &gt; inputmat[j][k]){ max += inputmat[i][k]; min += inputmat[j][k]; } else{ max += inputmat[j][k]; min += inputmat[i][k]; } } similaritymat[i][j] = max/min; } } """) #creating matrix mat = np.zeros(shape=(5,70)) mat[0][0]=6 mat[0][1]=4 mat[0][2]=9 mat[1][0]=35 mat[1][1]=22 mat[1][3]=65 mat[2][1]=9 mat[2][2]=30 mat[0][3]=45 mat[0][6]=85 mat[2][0]=10 mat[4][0]=37 mat[4][2]=2 mat[4][6]=67 mat[4][3]=77 mat[2][3]=12 mat[3][3]=5 mat[3][2]=56 similarity = np.zeros(shape=(5,5)) mat1 = mat.astype(np.int32) similarity1 = similarity.astype(np.float32) print(mat1) similarityGPU = mod.get_function("similarityGPU") similarityGPU( drv.In(mat1), drv.Out(similarity1), block=(5,70,1), grid=(1,1)) print (similarity1) print ("Total GPU Code execution took :",time.clock() - start_time, "seconds.")</code></pre> </div> </div> </p> <p>But, this code does not work for large dataset. I have inputmat[200][15000] and I need to get similaritymat[200][200], I tried blocksize=(200,15000,1) , but the code fails.</p> <p>Can anyone tell me how to make it work for <strong>large matrix</strong>? I'm using NVIDIA geForce GTX 960M. </p>