I'm copying via pycuda some arrays on the GPU and then store the pointers to these arrays. How do I recuperate the data back?
dist = np.zeros(numPoints).astype(np.float32)
distAddress = [gpuarray.to_gpu(dist).ptr for i in range(100)]
If I call the memcpy_dtoh function:
buf = np.zeros(400).astype(np.float32)
cuda.memcpy_dtoh(buf,distAddress[0])
, (where type(distAddress[0])
is long
) I get the following error:
cuda.memcpy_dtoh(buf, distAddress[0])
LogicError: cuMemcpyDtoH failed: invalid argument
What am I doing wrong?
Thanks!
I think if you are using GPUArrays
the way to copy from device to host is with the .get()
method. For example
dist = np.zeros(num_points).astype(np.float32)
dist_list = [gpuarray.to_gpu(dist) for i in range(100)]
buf = dist_list[0].get()