Hello.
During work on packaging new version of PyCUDA and PyOpenCL
I have discovered that test_array gives error when testing
new reduction code:
============================= test session starts
==============================
platform linux2 -- Python 2.6.6 -- pytest-1.3.4
test path 1: test_array.py
test_array.py .........................F.
=================================== FAILURES
===================================
test_scan[ctx_getter=<context getter for <pyopencl.Device 'ION' at
0x19c3a40>>]
ctx_getter = <pyopencl.tools.ContextGetter instance at 0x1a2ea28>
@pytools.test.mark_test.opencl
def test_scan(ctx_getter):
context = ctx_getter()
queue = cl.CommandQueue(context)
from pyopencl.scan import InclusiveScanKernel,
ExclusiveScanKernel
dtype = np.int32
for cls in [ExclusiveScanKernel, InclusiveScanKernel]:
knl = cls(context, dtype, "a+b", "0")
for n in [
10, 2**10-5, 2**10,
2**20-2**18,
2**20-2**18+5,
2**10+5,
2**20+5,
2**20, 2**24
]:
host_data = np.random.randint(0, 10, n).astype(dtype)
dev_data = cl_array.to_device(queue,
host_data)
test_array.py:578:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
_ _ _ _
def to_device(*args, **kwargs):
"""Converts a numpy array to a :class:`Array`."""
def _to_device(queue, ary, allocator=None, async=False):
result = Array(queue, ary.shape, ary.dtype, allocator,
strides=ary.strides)
result.set(ary, async=async)
return result
if isinstance(args[0], cl.Context):
from warnings import warn
warn("Passing a context as first argument is deprecated. "
"This will be continue to be accepted througout "
"versions 2011.x of PyOpenCL.",
DeprecationWarning, 2)
args = args[1:]
return _to_device(*args, **kwargs)
/usr/lib/python2.6/dist-packages/pyopencl/array.py:717:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
_ _ _ _
queue = <pyopencl._cl.CommandQueue object at 0x1a3c208>
ary = array([9, 8, 7, ..., 1, 7, 7], dtype=int32), allocator = None
async = False
def _to_device(queue, ary, allocator=None, async=False):
result = Array(queue, ary.shape, ary.dtype, allocator,
strides=ary.strides)
result.set(ary, async=async)
/usr/lib/python2.6/dist-packages/pyopencl/array.py:705:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
_ _ _ _
self = array([ 0, 8, 8, ..., 57645970, 57645973,
57645979], dtype=int32)
ary = array([9, 8, 7, ..., 1, 7, 7], dtype=int32), queue = None, async =
False
def set(self, ary, queue=None, async=False):
assert ary.size == self.size
assert ary.dtype == self.dtype
assert self.flags.forc
if not ary.flags.forc:
if async:
raise RuntimeError("cannot asynchronously set from "
"non-contiguous array")
ary = ary.copy()
if self.size:
cl.enqueue_copy(queue or self.queue, self.data, ary,
is_blocking=not async)
/usr/lib/python2.6/dist-packages/pyopencl/array.py:360:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
_ _ _ _
queue = <pyopencl._cl.CommandQueue object at 0x1a3c208>
dest = <pyopencl._cl.Buffer object at 0x2650910>
src = array([9, 8, 7, ..., 1, 7, 7], dtype=int32)
def enqueue_copy(queue, dest, src, **kwargs):
if isinstance(dest, Buffer):
if isinstance(src, Buffer):
if "src_origin" in kwargs:
return _cl._enqueue_copy_buffer_rect(queue, src,
dest, **kwargs)
else:
kwargs["dst_offset"] = kwargs.pop("dest_offset",
0)
return _cl._enqueue_copy_buffer(queue, src, dest,
**kwargs)
elif isinstance(src, Image):
return _cl._enqueue_copy_image_to_buffer(queue, src,
dest, **kwargs)
else:
# assume from-host
if "buffer_origin" in kwargs:
return _cl._enqueue_write_buffer_rect(queue, dest,
src, **kwargs)
else:
return
_cl._enqueue_write_buffer(queue, dest, src,
**kwargs)
E MemoryError: clEnqueueWriteBuffer failed: mem object
allocation failure
/usr/lib/python2.6/dist-packages/pyopencl/__init__.py:525: MemoryError
------------------------------- Captured stderr
--------------------------------
/usr/lib/python2.6/dist-packages/pyopencl/__init__.py:163: UserWarning:
Build succeeded, but resulted in non-empty logs:
Build on <pyopencl.Device 'ION' at 0x19c3a40> succeeded, but said:
: Considering profile 'compute_11' for gpu='sm_11' in
'cuModuleLoadDataEx_9c'
warn("Build succeeded, but resulted in non-empty logs:\n"+message)
/usr/lib/python2.6/dist-packages/pyopencl/__init__.py:163: UserWarning:
Build succeeded, but resulted in non-empty logs:
Build on <pyopencl.Device 'ION' at 0x19c3a40> succeeded, but said:
: Considering profile 'compute_11' for gpu='sm_11' in
'cuModuleLoadDataEx_9d'
warn("Build succeeded, but resulted in non-empty logs:\n"+message)
/usr/lib/python2.6/dist-packages/pyopencl/cache.py:336: UserWarning:
Build succeeded, but resulted in non-empty logs:
Build on <pyopencl.Device 'ION' at 0x19c3a40> succeeded, but said:
: Considering profile 'compute_11' for gpu='sm_11' in
'cuModuleLoadDataEx_9c'
warn("Build succeeded, but resulted in non-empty logs:\n"+message)
/usr/lib/python2.6/dist-packages/pyopencl/__init__.py:163: UserWarning:
Build succeeded, but resulted in non-empty logs:
Build on <pyopencl.Device 'ION' at 0x19c3a40> succeeded, but said:
: Considering profile 'compute_11' for gpu='sm_11' in
'cuModuleLoadDataEx_9e'
warn("Build succeeded, but resulted in non-empty logs:\n"+message)
/usr/lib/python2.6/dist-packages/pyopencl/__init__.py:163: UserWarning:
Build succeeded, but resulted in non-empty logs:
Build on <pyopencl.Device 'ION' at 0x19c3a40> succeeded, but said:
: Considering profile 'compute_11' for gpu='sm_11' in
'cuModuleLoadDataEx_9f'
warn("Build succeeded, but resulted in non-empty logs:\n"+message)
===================== 1 failed, 26 passed in 56.81 seconds
=====================
Error is caused by lack of memory on my ION.
After forcing garbage collection (attached patch)
all tests run without problems:
============================= test session starts
==============================
platform linux2 -- Python 2.6.6 -- pytest-1.3.4
test path 1: test_array.py
test_array.py ...........................
========================== 27 passed in 20.04 seconds
==========================
Regards
--
Tomasz Rybak <bogomips(a)post.pl> GPG/PGP key ID: 2AD5 9860
Fingerprint A481 824E 7DD3 9C0E C40A 488E C654 FB33 2AD5 9860
http://member.acm.org/~tomaszrybak