The current HEAD does not work correctly with Python 3. Running the testsuite on Python 2.7 (on Ubuntu 14.04) gives me:
pycuda$ python test/test_gpuarray.py
=== test session starts ===
platform linux2 -- Python 2.7.6 -- py-1.4.20 -- pytest-2.5.2
collected 51 items
test/test_gpuarray.py ...................................................
=== 51 passed in 231.07 seconds ===
python3 test/test_gpuarray.py
============================= test session starts ==============================
platform linux -- Python 3.4.0 -- py-1.4.22 -- pytest-2.6.0
collected 51 items
test/test_gpuarray.py .........F...................F.....................
=================================== FAILURES ===================================
_________________________ TestGPUArray.test_2d_slice_f _________________________
args = (<test_gpuarray.TestGPUArray object at 0x7f5b8bd79f28>,), kwargs = {}
pycuda = <module 'pycuda' from '/usr/local/lib/python3.4/dist-packages/pycuda-2013.1.1-py3.4-linux-x86_64.egg/pycuda/__init__.py'>
ctx = <pycuda._driver.Context object at 0x7f5b8bd753c8>
clear_context_caches = <function clear_context_caches at 0x7f5b96085378>
collect = <built-in function collect>
def f(*args, **kwargs):
import pycuda.driver
# appears to be idempotent, i.e. no harm in calling it more than once
pycuda.driver.init()
ctx = make_default_context()
try:
assert isinstance(ctx.get_device().name(), str)
assert isinstance(ctx.get_device().compute_capability(), tuple)
assert isinstance(ctx.get_device().get_attributes(), dict)
> inner_f(*args, **kwargs)
/usr/local/lib/python3.4/dist-packages/pycuda-2013.1.1-py3.4-linux-x86_64.egg/pycuda/tools.py:451:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
test/test_gpuarray.py:588: in test_2d_slice_f
a = a_gpu_f.get()
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <[TypeError("expected an object with a writable buffer interface") raised in repr()] GPUArray object at 0x7f5b8bd79b70>
ary = array([[ 0.00000000e+00, 1.35631280e-19, 4.74273749e+30, ...,
1.80602727e+28, 8.13464249e+32, 1.186... 3.60627856e+03, 1.40870256e+01, ...,
1.84612119e+20, 8.90377656e-15, 3.28151813e-18]], dtype=float32)
pagelocked = False
def get(self, ary=None, pagelocked=False):
if ary is None:
if pagelocked:
ary = drv.pagelocked_empty(self.shape, self.dtype)
else:
ary = np.empty(self.shape, self.dtype)
ary = _as_strided(ary, strides=self.strides)
else:
assert ary.size == self.size
assert ary.dtype == self.dtype
assert ary.flags.forc
assert self.flags.forc, "Array in get() must be contiguous"
if self.size:
> drv.memcpy_dtoh(ary, self.gpudata)
E TypeError: expected an object with a writable buffer interface
/usr/local/lib/python3.4/dist-packages/pycuda-2013.1.1-py3.4-linux-x86_64.egg/pycuda/gpuarray.py:265: TypeError
____________________ TestGPUArray.test_stride_preservation _____________________
args = (<test_gpuarray.TestGPUArray object at 0x7f5b8290fdd8>,), kwargs = {}
pycuda = <module 'pycuda' from '/usr/local/lib/python3.4/dist-packages/pycuda-2013.1.1-py3.4-linux-x86_64.egg/pycuda/__init__.py'>
ctx = <pycuda._driver.Context object at 0x7f5b82905518>
clear_context_caches = <function clear_context_caches at 0x7f5b96085378>
collect = <built-in function collect>
def f(*args, **kwargs):
import pycuda.driver
# appears to be idempotent, i.e. no harm in calling it more than once
pycuda.driver.init()
ctx = make_default_context()
try:
assert isinstance(ctx.get_device().name(), str)
assert isinstance(ctx.get_device().compute_capability(), tuple)
assert isinstance(ctx.get_device().get_attributes(), dict)
> inner_f(*args, **kwargs)
/usr/local/lib/python3.4/dist-packages/pycuda-2013.1.1-py3.4-linux-x86_64.egg/pycuda/tools.py:451:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
test/test_gpuarray.py:736: in test_stride_preservation
AT_GPU = gpuarray.to_gpu(AT)
/usr/local/lib/python3.4/dist-packages/pycuda-2013.1.1-py3.4-linux-x86_64.egg/pycuda/gpuarray.py:914: in to_gpu
result.set(ary)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <[TypeError("expected an object with a writable buffer interface") raised in repr()] GPUArray object at 0x7f5b8290fcc0>
ary = array([[ 0.09840709, 0.52116679, 0.16925525],
[ 0.33036802, 0.95108236, 0.43318754],
[ 0.73978786, 0.71290125, 0.21846779]])
def set(self, ary):
assert ary.size == self.size
assert ary.dtype == self.dtype
if ary.strides != self.strides:
from warnings import warn
warn("Setting array from one with different strides/storage order. "
"This will cease to work in 2013.x.",
stacklevel=2)
assert self.flags.forc
if self.size:
> drv.memcpy_htod(self.gpudata, ary)
E ValueError: ndarray is not C-contiguous
/usr/local/lib/python3.4/dist-packages/pycuda-2013.1.1-py3.4-linux-x86_64.egg/pycuda/gpuarray.py:229: ValueError
----------------------------- Captured stdout call -----------------------------
True False
===================== 2 failed, 49 passed in 45.45 seconds =====================