On Mon, 2 May 2011 15:00:09 -0400, Gaston Fiore <gaston.fi...@gmail.com> wrote:
> Hello,
> 
> When I run the code attached (very short), and I get error below:
> 
> -bash-3.2$ python test.py
> Traceback (most recent call last):
>   File "test.py", line 49, in <module>
>     (height + block_size - 1) // block_size))
>   File 
> "/home/gafiore/local/lib/python2.7/site-packages/pycuda-2011.1-py2.7-linux-x86_64.egg/pycuda/driver.py",
> line 172, in function_call
>     handler.pre_call(stream)
>   File 
> "/home/gafiore/local/lib/python2.7/site-packages/pycuda-2011.1-py2.7-linux-x86_64.egg/pycuda/driver.py",
> line 70, in pre_call
>     memcpy_htod(self.get_device_alloc(), self.array)
> TypeError: expected a single-segment buffer object
> -bash-3.2$ python test.py
> 
> However, if I comment out lines 7-9 and uncomment lines 9-10, which
> should result in identical NumPy arrays lat and lon, the code runs
> without any errors. How could this be possible? Aren't the arrays lat
> and lon equivalent in both cases?

Equivalent in the '==' sense, yes. But their memory layout is not
contiguous, which is a prerequisite for being able to copy them to the
GPU. (see numpy docs for an explanation of memory layouts and
contiguity) A simple numpy_array.copy() will fix that.

Andreas

Attachment: pgpMuXb3xRbRN.pgp
Description: PGP signature

_______________________________________________
PyCUDA mailing list
PyCUDA@tiker.net
http://lists.tiker.net/listinfo/pycuda

Reply via email to