I am trying to sum up an array in the GPU and then obtain it back on the host. For this, I am using the pycuda.gpuarray.sum()
function.
import pycuda.gpuarray
a = np.array([1,2,3,4,5])
b = gpuarray.to_gpu(a)
c = gpuarray.sum(b)
c = c.get()
print(c) #Prints array(15)
print(type(c)) #Prints numpy.ndarray
print(c[0]) #Error, Index error - too many indices for array
print(c.shape) #Prints (), empty tuple
How to I obtain the solution of the sum()
function back as a normal integer element?