[PyCuda] Python 2.6: longobject.c: bad argument to internal function
catanzar at eecs.berkeley.edu
Tue May 19 08:52:10 PDT 2009
The numpy ticket for this problem is here:
On Mon, May 18, 2009 at 4:26 PM, Andreas Klöckner
<lists at informa.tiker.net> wrote:
> Hi Bryan,
> first off, please make sure your replies stay on-list.
> On Montag 18 Mai 2009, Bryan Catanzaro wrote:
>> I'm using Python 2.6.2, Numpy 1.3.0, Boost 1.35, PyCUDA 0.93rc1 (which
>> I got from your git repository last week).
>> The error comes from the pack() function - it seems to stem from
>> packing a numpy integer (signed or unsigned) into a C struct with an
>> unsigned integer element. For example, this code fails with the same
>> import numpy
>> import struct
>> format = "L"
>> args = [numpy.uint32(1000000)]
>> print(struct.pack(format, *args))
>> First, I get a deprecation error:
>> sys:1: DeprecationWarning: struct integer overflow masking is deprecated
> Ah, I've gotten this warning before--and wondered what it was--but never the
> error you got. Thanks for tracking this down.
> It appears that the issue is mainly between struct.pack() and numpy then.
> PyCUDA is only peripherally involved. Your numpy is newer than mine--I'm still
> on 1.2.1. Maybe this was introduced in 1.3? What do you get from
> ? Does that throw the same error?
>> And then the system error
>> SystemError: Objects/longobject.c:336: bad argument to internal function
>> I can get around this error with some ugliness:
>> In elementwise.get_elwise_kernel_and_types, if I add a line to filter
>> out any upper case 'I' or 'L' elements from the struct string:
>> arg_types = [get_arg_type(arg) for arg in arguments.split(",")]
>> arg_types = [x.lower() if ((x.lower() == 'i') or (x.lower() ==
>> 'l')) else x for x in arg_types]
>> func.prepare("".join(arg_types), (1,1,1))
> The difference here may be whether the conversion goes via long() or not.
>> I'm not sure what the right way to pack numpy integers into unsigned
>> integer elements in a C struct, but that seems to be where the problem
> The right course of action is probably to bring this up with the numpy
> developers. I'd suggest you file a numpy ticket. Once you do, please report
> the URL so that I can keep track of it.
More information about the PyCUDA